Advertisement
Davilae177

D_WEACipher_A++ 2020

Feb 14th, 2020 (edited)
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.38 KB | None | 0 0
  1. plot(close)
  2.  
  3.  
  4. study(title="D_Market Cipher A", shorttitle="D_WEACipher_A++", overlay=true)
  5.  
  6. // PARAMETERS {
  7.  
  8. // WaveTrend Overbought & Oversold lines
  9. obLevel = input(53, "WT Overbought Level 1")
  10. obLevel2 = input(60, "WT Overbought Level 2")
  11. osLevel = input(-53, "WT Oversold Level 1")
  12. osLevel2 = input(-60, "WT Oversold Level 2")
  13.  
  14. //EMA Ribbon
  15. showRibbon = input(true, "Show Ribbon")
  16.  
  17. ema_1 = input(5)
  18. ema_2 = input(11)
  19. ema_3 = input(15)
  20. ema_4 = input(18)
  21. ema_5 = input(21)
  22. ema_6 = input(24)
  23. ema_7 = input(28)
  24. ema_8 = input(34)
  25. // }
  26.  
  27.  
  28. // CALCULATE INDICATORS {
  29.  
  30. //EMA Ribbon
  31. ema1_ = ema(close, ema_1)
  32. ema2_ = ema(close, ema_2)
  33. ema3_ = ema(close, ema_3)
  34. ema4_ = ema(close, ema_4)
  35. ema5_ = ema(close, ema_5)
  36. ema6_ = ema(close, ema_6)
  37. ema7_ = ema(close, ema_7)
  38. ema8_ = ema(close, ema_8)
  39.  
  40. // RSI
  41. up = rma(max(change(close), 0), 14)
  42. down = rma(-min(change(close), 0), 14)
  43. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
  44.  
  45. // WT
  46. n1 = input(7, "WT Channel Length")
  47. n2 = input(12, "WT Average Length")
  48.  
  49. ap = input(ohlc4)
  50. esa = ema(ap, n1)
  51. de = ema(abs(ap - esa), n1)
  52. ci = (ap - esa) / (0.015 * de)
  53. tci = ema(ci, n2)
  54. wt1 = tci
  55. wt2 = sma(wt1, 3)
  56.  
  57. vwap_area = wt1 - wt2
  58.  
  59. // WaveTrend Conditions
  60. WTCross = cross(wt1, wt2)
  61. WTCrossUp = wt2 - wt1 <= 0
  62. WTCrossDown = wt2 - wt1 >= 0
  63. WTOverSold = wt2 <= osLevel2
  64. WTOverBought = wt2 >= obLevel2
  65.  
  66. // Signals
  67.  
  68. longEma = crossover(ema2_, ema8_)
  69. redCross = crossunder(ema1_, ema2_)
  70. blueTriangle = crossover(ema2_, ema3_)
  71. redDiamond = WTCross and WTCrossDown
  72. yellowCross = redDiamond and rsi <= 30 and wt2 <= osLevel
  73. bloodDiamond = redDiamond and redCross
  74. shortEma = crossover(ema8_, ema2_)
  75.  
  76.  
  77.  
  78. // } CALCULATE INDICATORS
  79.  
  80.  
  81. // DRAW {
  82.  
  83. // EMA Ribbon
  84. colorEma = ema8_ < ema2_ ? green : red
  85.  
  86. plot(ema1_, color=showRibbon ? #265aa6 : na, linewidth=2, transp=50, title="EMA 1")
  87. plot(ema2_, color=showRibbon ? #265aa6 : na, linewidth=2, transp=50, title="EMA 2")
  88. plot(ema3_, color=showRibbon ? #1976d2 : na, linewidth=2, transp=50, title="EMA 3")
  89. plot(ema4_, color=showRibbon ? #1976d2 : na, linewidth=2, transp=50, title="EMA 4")
  90. plot(ema5_, color=showRibbon ? #7fb3ff : na, linewidth=2, transp=50, title="EMA 5")
  91. plot(ema6_, color=showRibbon ? #7fb3ff : na, linewidth=2, transp=50, title="EMA 6")
  92. plot(ema7_, color=showRibbon ? #bbdefb : na, linewidth=2, transp=50, title="EMA 7")
  93. plot(ema8_, color=showRibbon ? #bbdefb : na, linewidth=2, transp=50, title="EMA 8")
  94.  
  95. plot(ema8_, color=showRibbon ? na : colorEma, linewidth=2, transp=50, title="EMA 8")
  96.  
  97. // SHAPES
  98. plotshape(longEma, style=shape.circle, color=#00ff00, transp=50, location=location.abovebar, size=size.tiny, title="Long EMA Signal")
  99. plotshape(shortEma, style=shape.circle, color=#ff0000, transp=50, location=location.abovebar, size=size.tiny, title="Short EMA Signal")
  100. plotshape(redCross, style=shape.xcross, color=#ff0000, transp=50, location=location.abovebar, size=size.tiny, title="Red cross")
  101. plotshape(blueTriangle, style=shape.triangleup, color=#0064ff, transp=50, location=location.abovebar, size=size.small, title="Blue Triangle")
  102. plotshape(redDiamond, style=shape.diamond, color=#ff0000, location=location.abovebar, size=size.tiny, title="Red Diamond", transp=25)
  103. plotshape(bloodDiamond, style=shape.diamond, color=#ff0000, location=location.abovebar, size=size.small, title="Blood Diamond", transp=15)
  104. plotshape(yellowCross, style=shape.xcross, color=yellow, location=location.abovebar, size=size.small, title="Yellow Cross", transp=25)
  105. // } DRAW
  106.  
  107.  
  108. // ALERTS {
  109. alertcondition(redDiamond != 0, "Red Diamond", "Red Diamond")
  110. alertcondition(bloodDiamond != 0, "Blood Diamond", "Blood Diamond")
  111. alertcondition(yellowCross != 0, "YellowX", "YellowX")
  112. alertcondition(redCross != 0, "RedX", "RedX")
  113. alertcondition(longEma != 0, "Longema", "Longema")
  114. alertcondition(blueTriangle != 0, "Bluetriangle", "Bluetriangle")
  115. //******************************************************************************************************************************************************************************************************
  116. src = close
  117. useCurrentRes = input(true, title="Use Current Chart Resolution?")
  118. resCustom = input(title="Use Different Timeframe? Uncheck Box Above", defval="D")
  119. len = input(20, title="Moving Average Length - LookBack Period")
  120. //period = input(defval=7, title="Tilson T3 Period", minval=1)
  121. factorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0)
  122. atype = input(1,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3")
  123. spc=input(false, title="Show Price Crossing 1st Mov Avg - Highlight Bar?")
  124. cc = input(true,title="Change Color Based On Direction?")
  125. smoothe = input(2, minval=1, maxval=10, title="Color Smoothing - Setting 1 = No Smoothing")
  126. doma2 = input(false, title="Optional 2nd Moving Average")
  127. spc2=input(false, title="Show Price Crossing 2nd Mov Avg?")
  128. len2 = input(50, title="Moving Average Length - Optional 2nd MA")
  129. sfactorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0)
  130. atype2 = input(1,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3")
  131. cc2 = input(true,title="Change Color Based On Direction 2nd MA?")
  132. warn = input(false, title="***You Can Turn On The Show Dots Parameter Below Without Plotting 2nd MA to See Crosses***")
  133. warn2 = input(false, title="***If Using Cross Feature W/O Plotting 2ndMA - Make Sure 2ndMA Parameters are Set Correctly***")
  134. sd = input(false, title="Show Dots on Cross of Both MA's")
  135.  
  136. res = useCurrentRes ? period : resCustom
  137. //hull ma definition
  138. hullma = wma(2*wma(src, len/2)-wma(src, len), round(sqrt(len)))
  139. //TEMA definition
  140. ema1 = ema(src, len)
  141. ema2 = ema(ema1, len)
  142. ema3 = ema(ema2, len)
  143. tema = 3 * (ema1 - ema2) + ema3
  144.  
  145. //Tilson T3
  146. factor = factorT3 *.10
  147. gd(src, len, factor) => ema(src, len) * (1 + factor) - ema(ema(src, len), len) * factor
  148. t3(src, len, factor) => gd(gd(gd(src, len, factor), len, factor), len, factor)
  149. tilT3 = t3(src, len, factor)
  150.  
  151.  
  152. avg = atype == 1 ? sma(src,len) : atype == 2 ? ema(src,len) : atype == 3 ? wma(src,len) : atype == 4 ? hullma : atype == 5 ? vwma(src, len) : atype == 6 ? rma(src,len) : atype == 7 ? 3 * (ema1 - ema2) + ema3 : tilT3
  153. //2nd Ma - hull ma definition
  154. hullma2 = wma(2*wma(src, len2/2)-wma(src, len2), round(sqrt(len2)))
  155. //2nd MA TEMA definition
  156. sema1 = ema(src, len2)
  157. sema2 = ema(sema1, len2)
  158. sema3 = ema(sema2, len2)
  159. stema = 3 * (sema1 - sema2) + sema3
  160.  
  161. //2nd MA Tilson T3
  162. sfactor = sfactorT3 *.10
  163. sgd(src, len2, sfactor) => ema(src, len2) * (1 + sfactor) - ema(ema(src, len2), len2) * sfactor
  164. st3(src, len2, sfactor) => sgd(sgd(gd(src, len2, sfactor), len2, sfactor), len2, sfactor)
  165. stilT3 = st3(src, len2, sfactor)
  166.  
  167. avg2 = atype2 == 1 ? sma(src,len2) : atype2 == 2 ? ema(src,len2) : atype2 == 3 ? wma(src,len2) : atype2 == 4 ? hullma2 : atype2 == 5 ? vwma(src, len2) : atype2 == 6 ? rma(src,len2) : atype2 == 7 ? 3 * (ema1 - ema2) + ema3 : stilT3
  168.  
  169. out = avg
  170. out_two = avg2
  171.  
  172. out1 = security(tickerid, res, out)
  173. out2 = security(tickerid, res, out_two)
  174.  
  175. //Formula for Price Crossing Moving Average #1
  176. cr_up = open < out1 and close > out1
  177. cr_Down = open > out1 and close < out1
  178. //Formula for Price Crossing Moving Average #2
  179. cr_up2 = open < out2 and close > out2
  180. cr_Down2 = open > out2 and close < out2
  181. //barcolor Criteria for Price Crossing Moving Average #1
  182. iscrossUp() => cr_up
  183. iscrossDown() => cr_Down
  184. //barcolor Criteria for Price Crossing Moving Average #2
  185. iscrossUp2() => cr_up2
  186. iscrossDown2() => cr_Down2
  187.  
  188. ma_up = out1 >= out1[smoothe]
  189. ma_down = out1 < out1[smoothe]
  190.  
  191. col = cc ? ma_up ? lime : ma_down ? red : aqua : aqua
  192. col2 = cc2 ? ma_up ? lime : ma_down ? red : aqua : white
  193.  
  194. circleYPosition = out2
  195.  
  196. plot(out1, title="Multi-Timeframe Moving Avg", linewidth=13, color = col)
  197. plot(doma2 and out2 ? out2 : na, title="2nd Multi-TimeFrame Moving Average", style=circles, linewidth=4, color=col2)
  198. plot(sd and cross(out1, out2) ? circleYPosition : na,style=cross, linewidth=15, color=aqua)
  199. //barcolor Plot for Price Crossing Moving Average #1
  200. barcolor(spc and iscrossUp() ? (iscrossUp() ? yellow : na) : na)
  201. barcolor(spc and iscrossDown() ? (iscrossDown() ? yellow : na) : na)
  202. //barcolor Plot for Price Crossing Moving Average #2
  203. barcolor(spc2 and iscrossUp2() ? (iscrossUp2() ? yellow : na) : na)
  204. barcolor(spc2 and iscrossDown2() ? (iscrossDown2() ? yellow : na) : na)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement