SHARE
TWEET

Untitled

selnomeria Oct 1st, 2019 (edited) 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // buggy code
  2.  
  3.  
  4.  
  5. declare upper;
  6. def dn=double.nan;
  7.  
  8. input dojiOn = yes; #Doji
  9. input ema105On = yes; #EMA
  10. input rsiDailyOn = yes; #RSI Daily
  11. input rsiIntradayOn = yes; #RSI Intraday
  12. input nr7On = no; #NR7
  13. input lh3On = no; #LH3
  14. input hl3On = no; #HL3
  15.  
  16. def hasVolume = volume > 1;
  17.  
  18. def range = absvalue(high-low);
  19. def range3rd = (range * .299);
  20. def dir = if  close>open then 1 else -1;
  21. def body = absvalue(close[0]-open[0]) <= (range * .17);
  22.  
  23.     def idd_upperWick = if dir==1 then (high-close<range3rd) else (high-open<range3rd);
  24.     def idd_lowerWick = if dir==1 then (open-low>=range3rd*2) else (close-low>=range3rd*2);
  25.     def idd_doji = idd_upperWick and idd_lowerWick and body and range < .75 and range > .05 and hasVolume;
  26. def isDragonflyDoji= idd_doji;
  27.  
  28.     def igd_upperWick = if dir==1 then (high-close>=range3rd*2) else (high-open>=range3rd*2);
  29.     def igd_lowerWick = if dir==1 then (open-low<range3rd) else (close-low<range3rd);
  30.     def igd_doji = igd_upperWick and igd_lowerWick and body and range < .75 and range > .05 and hasVolume;
  31. def isGravestoneDoji =igd_doji;
  32.  
  33.     def id_upperWick = if dir==1 then (high-close>=range3rd) else (high-open>=range3rd);
  34.     def id_lowerWick = if dir==1 then (open-low>=range3rd) else (close-low>=range3rd);
  35.     def id_doji = id_upperWick and id_lowerWick and body and range < .75 and range > .05 and hasVolume;
  36. def isDoji = id_doji;
  37.  
  38. def diff=absvalue(high - low);
  39.  
  40.     def in7_a= diff[0];
  41.     def in7_b= diff[1];
  42.     def in7_c= diff[2];
  43.     def in7_d= diff[3];
  44.     def in7_e= diff[4];
  45.     def in7_f= diff[5];
  46.     def in7_g= diff[6];
  47.     def in7_retval= in7_a <= in7_b and in7_a <= in7_c and in7_a <= in7_d and in7_a <= in7_e and in7_a <= in7_f and in7_a <= in7_g;
  48. def isNr7= if !isNan(in7_retval) and in7_retval then in7_a else 0;
  49.  
  50. def threeHigherLows= low[0]  >= low[1]  and low[1]  >= low[2];
  51.  
  52. def threeLowerHighs= high[2] >= high[1] and high[1] >= high[0];
  53.  
  54. def ema1 = MovingAverage(averagetype.exponential, close, 20);    def sma1 = MovingAverage(averagetype.simple, close, 20);
  55. def ema2 = MovingAverage(averagetype.exponential, close, 50);    def sma2 = MovingAverage(averagetype.simple, close, 50);
  56. def ema3 = MovingAverage(averagetype.exponential, close, 100);    def sma3 = MovingAverage(averagetype.simple, close, 100);
  57. def ema4 = MovingAverage(averagetype.exponential, close, 200);    def sma4 = MovingAverage(averagetype.simple, close, 200);
  58.  
  59. def aboveMovingAvg    = high > ema1 and high > ema2 and high > ema3 and high > ema4 and high > sma1 and high > sma2 and high > sma3; #and high > sma(close, 200)
  60. def belowMovingAvg    = low < ema1  and low < ema2  and low < ema3  and low < ema4  and low < sma1  and low < sma2  and low < sma3;  #and low < sma(close, 200)
  61.  
  62. #Definitions
  63. def agr= getaggregationperiod();
  64. def isintraday = agr<86400000;
  65. def dojiCandle = isDoji[0] or isGravestoneDoji[0] or isDragonflyDoji[0];
  66. def ndx  = if isDoji[2] or isGravestoneDoji[2] or isDragonflyDoji[2] then 2 else 1;
  67. def ndx1 = if isDoji[3] or isGravestoneDoji[3] or isDragonflyDoji[3] then 3 else ndx;
  68. def dojiDouble = (dojiCandle[0] and getvalue(dojiCandle,ndx1) ) and isintraday;
  69. def closeHigher = close[0] > getvalue(open,ndx1) and isintraday and hasVolume[0];
  70. def closeLower = close[0] < getvalue(open,ndx1) and isintraday and hasVolume[0];
  71. def lh3 = threeLowerHighs and isintraday and hasVolume[0];
  72. def hl3 = threeHigherLows and isintraday and hasVolume[0];
  73. def nr7Candle = isNr7[0] and isintraday and hasVolume[0];
  74. def rsi_fix = if close-close==0 then rsi(price=close, length= 14) else rsi_fix[1];
  75. def dojiOverbought = rsi_fix >= 60 and isintraday and hasVolume[0];
  76. def rsi_below =  rsi_fix <= 50;
  77. def dojiOversold_ =rsi_below and isintraday and hasVolume[0];
  78. def dojiOversold = if (isnan( dojiOversold_)) then dn else dojiOversold_ ;
  79.  
  80. def belowMAs = belowMovingAvg;
  81.  
  82. input aggregation_displacer=1;
  83.  
  84. #Guides
  85. def agr1    = if isintraday and agr<=aggregationperiod.THIRTY_MIN then aggregationperiod.THIRTY_MIN else agr;
  86. def ema105    = if !isintraday or agr>aggregationperiod.THIRTY_MIN then dn else  movingaverage(averagetype.exponential, close(period=agr1), 105)[aggregation_displacer];
  87. plot ema105_= if !ema105On then dn else ema105; ema105_.SetDefaultColor(color.pink); ema105_.SetLineWeight(4);
  88.  
  89. #def above105 = close >= ema105;
  90. #def below105 = close < ema105;
  91. def rsiDaily_ = rsi(price=close(period=aggregationperiod.DAY), length= 5)[aggregation_displacer];
  92. def rsiDaily = if !isnan(rsiDaily_) then rsiDaily_ else rsiDaily[1];
  93.  
  94. plot xxDN= rsiDaily; xxDN.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE); xxDN.SetDefaultColor(color.red);        xxDN.SetLineWeight(1);
  95.  
  96. plot x= if rsi_below then 1 else 2; x.setpaintingstrategy(paintingstrategy.values_below);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top