Davilae177

Multi MA

Nov 22nd, 2019
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.23 KB | None | 0 0
  1. //@version=3
  2. //
  3. // Draws an MA Ribbon
  4. //
  5. // Where this MA Ribbon differs is that it lets you see clearly whats going on with the chart as it that it doesn't obscure the Price Action as other ribbons tend to do
  6. //
  7. // Thus it draws an MA Ribbon that highlights major MA's and for easier visibility separates them into different groups including Custom MA's, Baseline MA's, T Line MA's, Short Term MA's and Long Term MA's.
  8. //
  9. // Choose between 11 different types of MA's thanks to JustUncleL and John F. Ehlers super smoother.
  10. //
  11. // T Lines and Fill are colored according to direction and strength
  12. //
  13. // Minor Base Line is colored according to its EMA / SMA cross;
  14. //
  15. // When Minor Base Line Direction is Up then Blue = Strength to Upside, Purple = Weakness to Upside
  16. // When Minor Base Line Direction is Down then Purple = Strength to Downside, Blue = Weakness to Downside
  17. //
  18. //
  19. // The + is for the Stop Loss Channel and the various signals and alerts that have been derived from;
  20. //
  21. // Market Cipher / Wave Trend indicators
  22. // TCG - OB / OS RSI Volume Climax
  23. // Momentum Setups as shown in the Martin Momentum Strategy
  24. //
  25. // PLEASE USE SIGNALS WITH CAUTION AS THEY HAVE NOT BEEN BACK TESTED
  26. //
  27. // Happy Trading and remember just follow the flow of the river!
  28. //
  29.  
  30. study(title="Multi MA Ribbon +", shorttitle="Multi MA Ribbon +", overlay=true)
  31.  
  32.  
  33. ShowTCGSignals = input(true, title="Signals - TCG - RSI OB / OS Volume Climax")
  34.  
  35.  
  36. ShowMCSignals = input(true, title="Signals - Market Cipher / Wave Trend")
  37.  
  38. MCFilterType = input(defval="Trend Filter", title="Signals - Market Cipher / Wave Trend - Filter Type", options=["Filter X + Trend Filter", "Trend Filter", "Filter X", "N/A"])
  39.  
  40.  
  41. ShowMomentumSetups = input(true, title="Signals - Momentum Setups")
  42.  
  43. MSFilterType = input(defval="Filter X + Trend Filter", title="Signals - Momentum Setups - Filter Type", options=["Filter X + Trend Filter", "Trend Filter", "Filter X", "N/A"])
  44.  
  45. MSLookBackFilterLength = input(1, title="Signals - Momentum Setups - Look Back Filter - Ignor The Next x Number of Setups", minval = 1, maxval = 10, step = 1)
  46.  
  47. MSPointerSizeIn = input(defval="Large", title="Signals - Momentum Setups - Pointer Size", options=["Small", "Large"])
  48.  
  49.  
  50. ShowStoplossChannel = input(false, title="Stop Loss Channel")
  51.  
  52. StopLossPeriodLookBack = input(8, title="Stop Loss Channel - Lookback Length")
  53.  
  54.  
  55. ShowMultiMARibbon = input(true, title="------------------ Multi MA Ribbon -----------------------")
  56.  
  57. TypeMA3toMA12 = input(defval="EMA", title="----- Type - MA 3 -- MA 12 -- Short to Mid Term Type -----", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  58.  
  59. TypeMA13toMA19 = input(defval="SMA", title="----- Type - MA 13 - MA 19 -- Long Term MA Type ----------", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  60.  
  61.  
  62. ////
  63.  
  64.  
  65. ShowMinorBaseLine = input(true, title="Minor Base Line")
  66. MinorBaseLineType = input(defval="EMA", title="MA - Minor Base Line - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  67. MinorBaseLineLength = input(defval=15, title="MA - Minor Base Line - Length", minval=1)
  68.  
  69.  
  70. ShowMajorBaseLine = input(true, title="Major Base Line")
  71. MajorBaseLineType = input(defval="SMA", title="MA - Major Base Line - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  72. MajorBaseLineLength = input(defval=50, title="MA - Major Base Line- Length", minval=1)
  73.  
  74.  
  75. ShowMA1 = input(true, title="MA - 1 - Minor T Line")
  76. type1 = input(defval="EMA", title="MA - 1 - Minor T Line - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  77. len1 = input(defval=3, title="MA - 1 - Minor T Line - Length", minval=1)
  78.  
  79.  
  80. ShowMA2 = input(true, title="MA - 2 - Major T Line")
  81. type2 = input(defval="EMA", title="MA - 2 - Major T Line - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  82. len2 = input(defval=8, title="MA - 2 - Major T Line - Length", minval=1)
  83.  
  84.  
  85. // Short to Mid Term MA's
  86.  
  87.  
  88. ShowMA3 = input(false, title="MA - 3")
  89. //type3 = input(defval="EMA", title="MA - 3 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  90. len3 = input(defval=15, title="MA - 3 - Length", minval=1)
  91.  
  92.  
  93. ShowMA4 = input(true, title="MA - 4")
  94. //type4 = input(defval="EMA", title="MA - 4 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  95. len4 = input(defval=20, title="MA - 4 - Length", minval=1)
  96.  
  97.  
  98. ShowMA5 = input(true, title="MA - 5")
  99. //type5 = input(defval="EMA", title="MA - 5 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  100. len5 = input(defval=25, title="MA - 5 - Length", minval=1)
  101.  
  102.  
  103. ShowMA6 = input(true, title="MA - 6")
  104. //type6 = input(defval="EMA", title="MA - 6 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  105. len6 = input(defval=30, title="MA - 6 - Length", minval=1)
  106.  
  107.  
  108. ShowMA7 = input(true, title="MA - 7")
  109. //type7 = input(defval="EMA", title="MA - 7 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  110. len7 = input(defval=35, title="MA - 7 - Length", minval=1)
  111.  
  112.  
  113. ShowMA8 = input(true, title="MA - 8")
  114. //type8 = input(defval="EMA", title="MA - 8 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  115. len8 = input(defval=40, title="MA - 8 - Length", minval=1)
  116.  
  117.  
  118. ShowMA9 = input(true, title="MA - 9")
  119. //type9 = input(defval="EMA", title="MA - 9 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  120. len9 = input(defval=45, title="MA - 9 - Length", minval=1)
  121.  
  122.  
  123. ShowMA10 = input(true, title="MA - 10")
  124. //type10 = input(defval="EMA", title="MA - 10 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  125. len10 = input(defval=50, title="MA - 10 - Length", minval=1)
  126.  
  127. ShowMA11 = input(false, title="MA - 11")
  128. //type11a = input(defval="EMA", title="MA - 11 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  129. len11 = input(defval=55, title="MA - 11 - Length", minval=1)
  130.  
  131.  
  132. ShowMA12 = input(false, title="MA - 12")
  133. //type12a = input(defval="EMA", title="MA - 12 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  134. len12 = input(defval=60, title="MA - 12 - Length", minval=1)
  135.  
  136.  
  137. // Long Term MA Inputs
  138.  
  139. ShowMA13 = input(true, title="MA - 13")
  140. //type13 = input(defval="SMA", title="MA - 13 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  141. len13 = input(defval=100, title="MA - 13 - Length", minval=1)
  142.  
  143.  
  144. ShowMA14 = input(true, title="MA - 14")
  145. //type14 = input(defval="SMA", title="MA - 14 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  146. len14 = input(defval=200, title="MA - 14 - Length", minval=1)
  147.  
  148.  
  149. ShowMA15 = input(true, title="MA - 15")
  150. //type15 = input(defval="SMA", title="MA - 15 - Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  151. len15 = input(defval=250, title="MA - 15 - Length", minval=1)
  152.  
  153.  
  154. ShowMA16 = input(true, title="MA - 16")
  155. //type16 = input(defval="SMA", title="MA - 16- Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  156. len16 = input(defval=300, title="MA - 16 - Length", minval=1)
  157.  
  158.  
  159. ShowMA17 = input(true, title="MA - 17")
  160. //type17 = input(defval="SMA", title="MA - 17- Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  161. len17 = input(defval=350, title="MA - 17 - Length", minval=1)
  162.  
  163. ShowMA18 = input(true, title="MA - 18")
  164. type18 = input(defval="SMA", title="MA - 18- Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  165. len18 = input(defval=400, title="MA - 18 - Length", minval=1)
  166.  
  167.  
  168. ShowMA19 = input(true, title="MA - 19")
  169. //type19 = input(defval="SMA", title="MA - 19- Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
  170. len19 = input(defval=450, title="MA - 19 - Length", minval=1)
  171.  
  172.  
  173. ma_src = input(close, title="MA Source")
  174.  
  175.  
  176. // Stop Loss Channel Calculations and Plots
  177.  
  178. xHighest = highest(StopLossPeriodLookBack)
  179. xLowest = lowest(StopLossPeriodLookBack)
  180. plot(ShowStoplossChannel? xHighest : na, color=red, linewidth=2, title="Short Stop Loss Channel - Ensure Good Risk To Reward")
  181. plot(ShowStoplossChannel? xLowest : na, color=green, linewidth=2, title="Long Stop Loss Channel - Ensure Good Risk To Reward")
  182.  
  183.  
  184. // - variant(type, src, len, gamma)
  185. // Returns MA input selection variant, default to SMA if blank or typo.
  186.  
  187. // SuperSmoother filter
  188. // © 2013 John F. Ehlers
  189. variant_supersmoother(src,len) =>
  190. a1 = exp(-1.414*3.14159 / len)
  191. b1 = 2*a1*cos(1.414*3.14159 / len)
  192. c2 = b1
  193. c3 = (-a1)*a1
  194. c1 = 1 - c2 - c3
  195. v9 = 0.0
  196. v9 := c1*(src + nz(src[1])) / 2 + c2*nz(v9[1]) + c3*nz(v9[2])
  197. v9
  198.  
  199. variant_smoothed(src,len) =>
  200. v5 = 0.0
  201. v5 := na(v5[1]) ? sma(src, len) : (v5[1] * (len - 1) + src) / len
  202. v5
  203.  
  204. variant_zerolagema(src,len) =>
  205. xLag = (len - 1) / 2
  206. xEMA = (src + (src - src[xLag]))
  207. v10 = ema(xEMA, len)
  208. v10
  209.  
  210. variant_doubleema(src,len) =>
  211. v2 = ema(src, len)
  212. v6 = 2 * v2 - ema(v2, len)
  213. v6
  214.  
  215. variant_tripleema(src,len) =>
  216. v2 = ema(src, len)
  217. v7 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len) // Triple Exponential
  218. v7
  219.  
  220.  
  221. // return variant, defaults to SMA
  222. variant(type, src, len) =>
  223. result = src
  224. if len>1
  225. result := type=="EMA" ? ema(src,len) :
  226. type=="WMA" ? wma(src,len):
  227. type=="VWMA" ? vwma(src,len) :
  228. type=="SMMA" ? variant_smoothed(src,len) :
  229. type=="DEMA" ? variant_doubleema(src,len):
  230. type=="TEMA" ? variant_tripleema(src,len):
  231. type=="HullMA"? wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) :
  232. type=="SSMA" ? variant_supersmoother(src,len) :
  233. type=="ZEMA" ? variant_zerolagema(src,len) :
  234. type=="TMA" ? sma(sma(src,len),len) :
  235. sma(src,len)
  236. //end if
  237. result
  238.  
  239.  
  240. // MA Calculations
  241.  
  242. MinorBaseLine = variant(MinorBaseLineType , ma_src, MinorBaseLineLength)
  243. MajorBaseLine = variant(MajorBaseLineType , ma_src, MajorBaseLineLength)
  244.  
  245. MA1 = variant(type1, ma_src, len1)
  246. MA2 = variant(type2, ma_src, len2)
  247.  
  248. // Short to Mid Term MA's
  249.  
  250. MA3 = variant(TypeMA3toMA12, ma_src, len3)
  251. MA4 = variant(TypeMA3toMA12, ma_src, len4)
  252. MA5 = variant(TypeMA3toMA12, ma_src, len5)
  253. MA6 = variant(TypeMA3toMA12, ma_src, len6)
  254. MA7 = variant(TypeMA3toMA12, ma_src, len7)
  255. MA8 = variant(TypeMA3toMA12, ma_src, len8)
  256. MA9 = variant(TypeMA3toMA12, ma_src, len9)
  257. MA10 = variant(TypeMA3toMA12, ma_src, len10)
  258. MA11 = variant(TypeMA3toMA12, ma_src, len11)
  259. MA12 = variant(TypeMA3toMA12, ma_src, len12)
  260.  
  261. // Long Term MA's
  262.  
  263. MA13 = variant(TypeMA13toMA19, ma_src, len13)
  264. MA14 = variant(TypeMA13toMA19, ma_src, len14)
  265. MA15 = variant(TypeMA13toMA19, ma_src, len15)
  266. MA16 = variant(TypeMA13toMA19, ma_src, len16)
  267. MA17 = variant(TypeMA13toMA19, ma_src, len17)
  268. MA18 = variant(TypeMA13toMA19, ma_src, len18)
  269. MA19 = variant(TypeMA13toMA19, ma_src, len19)
  270.  
  271.  
  272. // MA Colors
  273.  
  274. MinorBaseLineSMA = variant("SMA" , ma_src, MinorBaseLineLength)
  275. MinorBaseLineEMA = variant("EMA" , ma_src, MinorBaseLineLength)
  276. MinorBaseLineEMAAboveSMA = MinorBaseLineEMA > MinorBaseLineSMA ? 1 : 0
  277.  
  278. MinorBaseLineColor = MinorBaseLineEMAAboveSMA ? color(blue, 30) : color(purple, 40)
  279. MajorBaseLineColor = MajorBaseLine > MajorBaseLine[1] ? #00ff00 : #ff0000
  280.  
  281. MA1Color = MA1 > MA1[1] ? green : green
  282.  
  283. MA2Colora = MA1 > MA2 ? color(green, 0) : color(red, 0)
  284. MA2Colorb = MA1 > MA2 ? color(lime, 0) : na
  285.  
  286. // version 127
  287.  
  288. MA3Color = MA3 > MA3[1] ? color(green, 89) : color(red, 89)
  289.  
  290. MA4Color = MA4 > MA4[1] ? color(green, 67) : color(red, 76)
  291.  
  292. MA5Color = MA5 > MA5[1] ? color(green, 89) : color(red, 89)
  293.  
  294. MA6Color = MA6 > MA6[1] ? color(green, 67) : color(red, 76)
  295.  
  296. MA7Color = MA7 > MA7[1] ? color(green, 89) : color(red, 89)
  297.  
  298. MA8Color = MA8 > MA8[1] ? color(green, 67) : color(red, 76)
  299.  
  300. MA9Color = MA9 > MA9[1] ? color(green, 89) : color(red, 89)
  301.  
  302. MA10Color = MA10 > MA10[1] ? color(green, 67) : color(red, 76)
  303.  
  304. MA11Color = MA11 > MA11[1] ? color(green, 89) : color(red, 89)
  305.  
  306. MA12Color = MA12 > MA12[1] ? color(green, 67) : color(red, 76)
  307.  
  308.  
  309. MA13Color = color(orange, 5) //MA13 > MA13[1] ? color(orange, 5) : color(orange, 5)
  310.  
  311. MA14Color = color(red, 10) //MA14 > MA14[1] ? color(red, 10) : color(red, 10)
  312.  
  313. MA15Color = #B2222233 //MA15 > MA15[1] ? #B2222233 : #B2222233
  314.  
  315. MA16Color = #B2222233 //MA16 > MA16[1] ? #B2222233 : #B2222233
  316.  
  317. MA17Color = #B2222233 //MA17 > MA17[1] ? #B2222233 : #B2222233
  318.  
  319. MA18Color = #B2222233 //MA18 > MA18[1] ? #B2222233 : #B2222233
  320.  
  321. MA19Color = #B2222233 //MA19 > MA19[1] ? #B2222233 : #B2222233
  322.  
  323.  
  324. TLineFillColor = close > MA1 ? lime : red
  325.  
  326.  
  327. // MA Plots
  328.  
  329. // Baseline MA Plots
  330.  
  331. plot(ShowMultiMARibbon and ShowMinorBaseLine? MinorBaseLine : na, title="Minor Base Line", color=MinorBaseLineColor, linewidth=2)
  332.  
  333. plot(ShowMultiMARibbon and ShowMajorBaseLine? MajorBaseLine : na, title="Major Base Line", color=MajorBaseLineColor, transp= 40, linewidth=3)
  334.  
  335.  
  336. // T Line MA Plots
  337.  
  338. a=plot(ShowMultiMARibbon and ShowMA1? MA1 : na, title="MA - 1 - Minor T Line", color=MA1Color, linewidth=1)
  339.  
  340. b=plot(ShowMultiMARibbon and ShowMA2? MA2 : na, title="MA - 2 - Minor T Line - Color a", color=MA2Colora, linewidth=1)
  341.  
  342. plot(ShowMultiMARibbon and ShowMA2? MA2 : na, title="MA - 2 - Minor T Line - Color b", color=MA2Colorb, linewidth=1)
  343.  
  344. fa=fill(a, b, color=TLineFillColor, transp=95, title="Fill - T Line Fill")
  345.  
  346.  
  347. // Short to Mid Term MA Plots
  348.  
  349. plot(ShowMultiMARibbon and ShowMA3? MA3 : na, title="MA - 3", color=MA3Color, linewidth=2)
  350.  
  351. plot(ShowMultiMARibbon and ShowMA4? MA4 : na, title="MA - 4", color=MA4Color, linewidth=1)
  352.  
  353. plot(ShowMultiMARibbon and ShowMA5? MA5 : na, title="MA - 5", color=MA5Color, linewidth=1)
  354.  
  355. plot(ShowMultiMARibbon and ShowMA6? MA6 : na, title="MA - 6", color=MA6Color, linewidth=1)
  356.  
  357. plot(ShowMultiMARibbon and ShowMA7? MA7 : na, title="MA - 7", color=MA7Color, linewidth=1)
  358.  
  359. plot(ShowMultiMARibbon and ShowMA8? MA8 : na, title="MA - 8", color=MA8Color, linewidth=1)
  360.  
  361. plot(ShowMultiMARibbon and ShowMA9? MA9 : na, title="MA - 9", color=MA9Color, linewidth=1)
  362.  
  363. plot(ShowMultiMARibbon and ShowMA10? MA10 : na, title="MA - 10", color=MA10Color, linewidth=1)
  364.  
  365. plot(ShowMultiMARibbon and ShowMA11? MA11 : na, title="MA - 11", color=MA11Color, linewidth=1)
  366.  
  367. plot(ShowMultiMARibbon and ShowMA12? MA12 : na, title="MA - 12", color=MA12Color, linewidth=1) ////////////////////////
  368.  
  369.  
  370. // Long Term MA Plots
  371.  
  372. plot(ShowMultiMARibbon and ShowMA13? MA13 : na, title="MA - 13", color=MA13Color, linewidth=1)
  373.  
  374. c=plot(ShowMultiMARibbon and ShowMA14? MA14 : na, title="MA - 14", color=MA14Color, linewidth=1)
  375.  
  376. d=plot(ShowMultiMARibbon and ShowMA15? MA15 : na, title="MA - 15", color=MA15Color, linewidth=1)
  377.  
  378. e=plot(ShowMultiMARibbon and ShowMA16? MA16 : na, title="MA - 16", color=MA16Color, linewidth=1)
  379.  
  380. f=plot(ShowMultiMARibbon and ShowMA17? MA17 : na, title="MA - 17", color=MA17Color, linewidth=1)
  381.  
  382. g=plot(ShowMultiMARibbon and ShowMA18? MA18 : na, title="MA - 18", color=MA18Color, linewidth=1)
  383.  
  384. h=plot(ShowMultiMARibbon and ShowMA19? MA19 : na, title="MA - 19", color=MA19Color, linewidth=1)
  385.  
  386.  
  387. fb=fill(c, d, color=navy, transp=97, title="Fill - MA River - Long Term MA's")
  388. fc=fill(d, e, color=navy, transp=97, title="Fill - MA River - Long Term MA's")
  389. fd=fill(e, f, color=navy, transp=97, title="Fill - MA River - Long Term MA's")
  390. fe=fill(f, g, color=navy, transp=97, title="Fill - MA River - Long Term MA's")
  391. ff=fill(g, h, color=navy, transp=97, title="Fill - MA River - Long Term MA's")
  392.  
  393.  
  394. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  395.  
  396. // Signal Filters
  397.  
  398. FilterX = (ema(close,15) > sma(close,15)) and (ema(close,15)[1] > sma(close,15)[1]) ? 1 : 0
  399.  
  400. FilterXMC = (ema(close,15) > sma(close,15)) ? 1 : 0
  401.  
  402.  
  403. TrendFilterPlus = (ema(close,15) > ema(close,20)) and (ema(close,20) > ema(close,30)) and (ema(close,30) > ema(close,40)) and (ema(close,40) > ema(close,50)) ? 1 : 0
  404.  
  405. TrendFilterMinus = (ema(close,15) < ema(close,20)) and (ema(close,20) < ema(close,30)) and (ema(close,30) < ema(close,40)) and (ema(close,40) < ema(close,50)) ? 1 : 0
  406.  
  407.  
  408. //////// SIGNALS ////////////////////////////////////////////////////////
  409.  
  410. TCGInputs = input(true, title='---------- Inputs - TCG RSI OB / OS --------------------------')
  411.  
  412. Xb_Times = input(title="TCG - Abnormal Volume - Abnormal Volume Alert - Volume Deviation from SMA", minval=1, defval=2.75, step=0.25)
  413.  
  414.  
  415. Volume_SMA = input(title="TCG - Abnormal Volume - Volume SMA", minval=1, defval=20)
  416.  
  417.  
  418. //RSIOBOSVolClimax = input(true, title="RSI Over Bought / Over Sold Volume Climax")
  419.  
  420. RSILength = input(14, title="TCG - RSI OB/OS Volume Climax - RSI")
  421. RSIob = input(70, title="TCG - RSI OB/OS Volume Climax - RSI Overbought")
  422. RSIos = input(30, title="TCG - RSI OB/OS Volume Climax - RSI Oversold")
  423.  
  424.  
  425. Abnormal_Volume_Alert_Condition = volume > sma(volume[1], Volume_SMA) * Xb_Times ? 1 : 0
  426.  
  427.  
  428. // RSI OB/OS Volume Climax Calculations
  429.  
  430. RSI1 = rsi(close,RSILength)
  431.  
  432. RSIOB = RSI1 > RSIob? 1:0
  433. RSIOS = RSI1 < RSIos? 1:0
  434.  
  435. RSIOBClimax = RSIOB and Abnormal_Volume_Alert_Condition ? 1:0
  436. RSIOSClimax = RSIOS and Abnormal_Volume_Alert_Condition ? 1:0
  437.  
  438.  
  439. // RSI OB/OS Volume Climax
  440.  
  441. // RSI OB Volume Climax
  442.  
  443. plotshape(ShowTCGSignals and (RSI1 >= 70)? RSIOBClimax : na, title='RSI OB Volume Climax - RSI >= 70', location=location.abovebar, style=shape.arrowdown, size=size.tiny, text="█\n\n", color=red, transp=45)
  444.  
  445. plotshape(ShowTCGSignals and (RSI1 >= 75)? RSIOBClimax : na, title='RSI OB Volume Climax - RSI >= 75', location=location.abovebar, style=shape.arrowdown, size=size.tiny, text="█\n\n\n", color=red, transp=45)
  446.  
  447. plotshape(ShowTCGSignals and (RSI1 >= 80)? RSIOBClimax : na, title='RSI OB Volume Climax - RSI >= 80', location=location.abovebar, style=shape.arrowdown, size=size.tiny, text="█\n\n\n\n", color=red, transp=45)
  448.  
  449. plotshape(ShowTCGSignals and (RSI1 >= 85)? RSIOBClimax : na, title='RSI OB Volume Climax - RSI >= 85', location=location.abovebar, style=shape.arrowdown, size=size.tiny, text="█\n\n\n\n\n", color=red, transp=45)
  450.  
  451.  
  452. // RSI OS Volume Climax
  453.  
  454. plotshape(ShowTCGSignals and (RSI1 <= 30)? RSIOSClimax : na, title='RSI OS Volume Climax - RSI <= 30', location=location.belowbar, style=shape.arrowdown, size=size.tiny, text="\n\n\n█", color=green, transp=45)
  455.  
  456. plotshape(ShowTCGSignals and (RSI1 <= 25)? RSIOSClimax : na, title='RSI OS Volume Climax - RSI <= 25', location=location.belowbar, style=shape.arrowdown, size=size.tiny, text="\n\n\n\n█", color=green, transp=45)
  457.  
  458. plotshape(ShowTCGSignals and (RSI1 <= 20)? RSIOSClimax : na, title='RSI OS Volume Climax - RSI <= 20', location=location.belowbar, style=shape.arrowdown, size=size.tiny, text="\n\n\n\n\n█", color=green, transp=45)
  459.  
  460. plotshape(ShowTCGSignals and (RSI1 <= 15)? RSIOSClimax : na, title='RSI OS Volume Climax - RSI <= 15', location=location.belowbar, style=shape.arrowdown, size=size.tiny, text="\n\n\n\n\n\n█", color=green, transp=45)
  461.  
  462. ////////////////Signals - Market Cipher////////////////////////////////////////////////////////////////////////////////////////////////
  463.  
  464. MCInputs = input(true, title='---------- Inputs - Market Cipher / Wave Trend ---------------')
  465.  
  466. MCTranspIn = input(50, title="Market Cipher / Wave Trend - Signal Brightness", minval = 0, maxval = 100, step = 5)
  467.  
  468. // Market Cipher Transparency
  469.  
  470. MCTransp = 100 - MCTranspIn
  471.  
  472.  
  473. // Market Cipher / Wave Trend - Overbought & Oversold lines
  474. obLevel = input(53, "Market Cipher / Wave Trend - WT Overbought Level 1")
  475. obLevel2 = input(60, "Market Cipher / Wave Trend - WT Overbought Level 2")
  476. osLevel = input(-53, "Market Cipher / Wave Trend - WT Oversold Level 1")
  477. osLevel2 = input(-60, "Market Cipher / Wave Trend - WT Oversold Level 2")
  478.  
  479. // Market Cipher / Wave Trend - RSI
  480.  
  481. RSIMC = rsi(close,14)
  482.  
  483. // Market Cipher / Wave Trend
  484.  
  485. n1 = input(7, "Market Cipher / Wave Trend - WT Channel Length")
  486. n2 = input(12, "Market Cipher / Wave Trend - WT Average Length")
  487.  
  488. ap = input(ohlc4, "Market Cipher / Wave Trend - AP")
  489. esa = ema(ap, n1)
  490. de = ema(abs(ap - esa), n1)
  491. ci = (ap - esa) / (0.015 * de)
  492. tci = ema(ci, n2)
  493. wt1 = tci
  494. wt2 = sma(wt1, 3)
  495.  
  496. // Market Cipher / Wave Trend - Conditions
  497.  
  498. WTCross = cross(wt1, wt2)
  499. WTCrossUp = wt2 - wt1 <= 0
  500. WTCrossDown = wt2 - wt1 >= 0
  501. WTOverSold = wt2 <= osLevel2
  502. WTOverBought = wt2 >= obLevel2
  503.  
  504.  
  505. // Signals
  506. // Blue Triangle EMAs
  507.  
  508. BTFast = ema(close, 11)
  509. BTSlow = ema(close, 15)
  510.  
  511. //longEma = crossover(ema2_, ema8_)
  512. //shortEma = crossover(ema8_, ema2_)
  513. //blueTriangle = crossover(ema2_, ema3_)
  514.  
  515.  
  516. greenCross = crossover(ema(close,3), ema(close,8))
  517. redCross = crossunder(ema(close,3), ema(close,8))
  518.  
  519.  
  520. LongEma = crossover(ema(close, 11), ema(close, 36))
  521. ShortEma = crossunder(ema(close, 11), ema(close, 36))
  522.  
  523.  
  524. SmallGreenDiamond = MCFilterType=="Filter X"? FilterXMC and WTCross and WTCrossUp : MCFilterType=="Trend Filter"? TrendFilterPlus and WTCross and WTCrossUp : MCFilterType=="Filter X + Trend Filter"? FilterXMC and TrendFilterPlus and WTCross and WTCrossUp : WTCross and WTCrossUp
  525. SmallRedDiamond = MCFilterType=="Filter X"? not FilterXMC and WTCross and WTCrossDown : MCFilterType=="Trend Filter"? TrendFilterMinus and WTCross and WTCrossDown : MCFilterType=="Filter X + Trend Filter"? not FilterXMC and TrendFilterMinus and WTCross and WTCrossDown : WTCross and WTCrossDown
  526. BigGreenDiamond = MCFilterType=="Filter X"? FilterXMC and SmallGreenDiamond and greenCross : MCFilterType=="Trend Filter"? TrendFilterPlus and SmallGreenDiamond and greenCross : MCFilterType=="Filter X + Trend Filter"? FilterXMC and TrendFilterPlus and SmallGreenDiamond and greenCross : SmallGreenDiamond and greenCross
  527. BigRedDiamond = MCFilterType=="Filter X"? not FilterXMC and SmallRedDiamond and redCross : MCFilterType=="Trend Filter"? TrendFilterMinus and SmallRedDiamond and redCross : MCFilterType=="Filter X + Trend Filter"? not FilterXMC and TrendFilterMinus and SmallRedDiamond and redCross : SmallRedDiamond and redCross // bloodDiamond
  528. YellowCross = WTCross and WTCrossDown and RSIMC <= 30 and wt2 <= osLevel
  529. BlueTriangleUp = crossover(BTFast, BTSlow) and ema(close,3) > ema(close,15) and ema(close,8) > ema(close,15)
  530. BlueTriangleDown = crossunder(BTFast, BTSlow) and ema(close,3) < ema(close,15) and ema(close,8) < ema(close,15)
  531.  
  532.  
  533. // Plots - Market Cipher Signals
  534.  
  535. plotshape(ShowMCSignals and LongEma? LongEma : na, style=shape.circle, color=green, transp=MCTransp, location=location.abovebar, size=size.tiny, title="Long EMA Signal - 11 EMA Crossing Over 36 EMA - Caution Can Sometimes Signal Exhaustion")
  536.  
  537. plotshape(ShowMCSignals and ShortEma? ShortEma : na, style=shape.circle, color=red, transp=MCTransp, location=location.belowbar, size=size.tiny, title="Short EMA Signal- 11 EMA Crossing Under 36 EMA - Caution Can Sometimes Signal Exhaustion")
  538.  
  539.  
  540. plotshape(ShowMCSignals and SmallGreenDiamond and not BigGreenDiamond? SmallGreenDiamond : na, style=shape.diamond, color=green, transp=MCTransp, location=location.belowbar, size=size.tiny, title="Small Green Diamond - Cipher Cross and Cipher Cross Up")
  541.  
  542. plotshape(ShowMCSignals and SmallRedDiamond and not BigRedDiamond? SmallRedDiamond : na, style=shape.diamond, color=#ff0000, transp=MCTransp, location=location.abovebar, size=size.tiny, title="Small Red Diamond - Cipher Cross and Cipher Cross Down")
  543.  
  544.  
  545. plotshape(ShowMCSignals and BigGreenDiamond? BigGreenDiamond : na, style=shape.diamond, color=green, transp=MCTransp, location=location.belowbar, size=size.small, title="Big Green Diamond - Small Green Diamond and 3 EMA Crosses Over 8 EMA")
  546.  
  547. plotshape(ShowMCSignals and BigRedDiamond? BigRedDiamond : na, style=shape.diamond, color=#ff0000, transp=MCTransp, location=location.abovebar, size=size.small, title="Big Red Diamond / Blood Diamond - Small Red Diamond and 3 EMA Crosses Under 8 EMA")
  548.  
  549. // plotshape(ShowMCSignals and YellowCross? YellowCross : na, style=shape.xcross, color=orange, transp=MCTransp, location=location.abovebar, size=size.normal, title="Yellow Cross - Manipulation")
  550.  
  551. plotshape(ShowMCSignals and BlueTriangleUp? BlueTriangleUp : na, style=shape.triangleup, color=blue, transp=MCTransp, location=location.belowbar, size=size.small, title="Blue Triangle Up - T Lines Cross Over 15 EMA")
  552.  
  553. plotshape(ShowMCSignals and BlueTriangleDown? BlueTriangleDown : na, style=shape.triangledown, color=blue, transp=MCTransp, location=location.abovebar, size=size.small, title="Blue Triangle Down - T Lines Cross Under 15 EMA")
  554.  
  555.  
  556. ////////////////Signals - Momentum Strategy////////////////////////////////////////////////////////////////////////////////////////////////
  557.  
  558. // Momentum Strategy
  559. // Inputs / Menus and Calculations
  560. // Stochastics Inputs / Menus
  561. //ShowMomentumSetupStandardStoch = input(true, title="Show Momentum Setups - Stochastic")
  562. //ShowMomentumSetupRSIStoch = input(true, title="Show Momentum Setups - RSI Stochastic")
  563. //MSFilterInput = input(1, title="Filter - Ignor The Next x Number of Setups", minval = 1, maxval = 10, step = 1)
  564.  
  565. MSInputs = input(true, title='---------- Inputs - Momentum Setups --------------------------')
  566.  
  567. MSTranspIn = input(70, title="Momentum Setups - Signals Brightness", minval = 0, maxval = 100, step = 5)
  568.  
  569. MSTransp = 100 - MSTranspIn
  570.  
  571. // Stochastic Input
  572.  
  573. K1 = input(5, title="Momentum Setups - Stochastic - K")
  574. D1 = input(3, title="Momentum Setups - Stochastic - D")
  575. Smooth1 = input(2, title="Momentum Setups - Stochastic - Smoothing")
  576.  
  577.  
  578. // MS Inputs
  579.  
  580. MSTriggerMAType = input( title='Momentum Setups - Trigger MA - Type', defval="EMA", options=["EMA", "SMA"])
  581. MSTriggerMALength = input(8, title='Momentum Setups - Trigger MA - Length', minval=1)
  582.  
  583. MSMA1_Type = input( title='Momentum Setups - Cross Over Filter - Fast MA - Type', defval="EMA", options=["EMA", "SMA"])
  584. MSMA1_Length = input(13, title='Momentum Setups - Cross Over Filter - Fast MA - Length', minval=1)
  585.  
  586.  
  587. MSMA2_Type = input( title='Momentum Setups - Cross Over Filter - Slow MA - Type', defval="SMA", options=["EMA", "SMA"])
  588. MSMA2_Length = input(36, title='Momentum Setups - Cross Over Filter - Slow MA - Length', minval=1)
  589.  
  590.  
  591. MSOBThresholdUT = input(80, title="Momentum Setups - OB Threshold - Up Trend - Long Setups", minval = 60, maxval = 100, step = 1)
  592. MSOSThresholdUT = input(20, title="Momentum Setups - OS Threshold - Up Trend - Long Setups", minval = 0, maxval = 40, step = 1)
  593. MSOBThresholdDT = input(80, title="Momentum Setups - OB Threshold - Down Trend - Short Setups", minval = 60, maxval = 100, step = 1)
  594. MSOSThresholdDT = input(20, title="Momentum Setups - OS Threshold - Down Trend - Short Setups", minval = 0, maxval = 40, step = 1)
  595.  
  596.  
  597. // Calculations for Stochastic
  598.  
  599. hh1 = highest(high, K1)
  600. ll1 = lowest(low, K1)
  601. KStandardStoch = sma((close - ll1) / (hh1 - ll1) * 100, Smooth1)
  602. DStandardStoch = sma(KStandardStoch, D1)
  603.  
  604.  
  605. StandardStochasticKAbove50 = KStandardStoch >= 50 ? 1 : 0 //////////////////////////////////////////////////////////
  606. StandardStochasticDAbove50 = DStandardStoch >= 50 ? 1 : 0 //////////////////////////////////////////////////////////
  607. StandardStochasticKAboveD = KStandardStoch > DStandardStoch ? 1 : 0
  608.  
  609.  
  610. // Momentum Setups - Cross Over Filter - MA Calculations
  611.  
  612. TriggerMA = if MSMA1_Type == "SMA"
  613. sma(close, MSTriggerMALength)
  614. else
  615. ema(close, MSTriggerMALength)
  616.  
  617.  
  618. MSMA1 = if MSMA1_Type == "SMA"
  619. sma(close, MSMA1_Length)
  620. else
  621. ema(close, MSMA1_Length)
  622.  
  623.  
  624. MSMA2 = if MSMA2_Type == "SMA"
  625. sma(close, MSMA2_Length)
  626. else
  627. ema(close, MSMA2_Length)
  628.  
  629. // MA Crossover Condition
  630.  
  631. MSMACrossover = MSMA1 > MSMA2 ? 1 : 0
  632.  
  633. MSMA1Direction = MSMA1 > MSMA1[1] ? 1 : 0
  634.  
  635. MSMA2Direction = MSMA2 > MSMA2[1] ? 1 : 0
  636.  
  637.  
  638. // Momentum Setups - MACD and MOM & DAD - Top Dog Trading
  639.  
  640. // Momentum Setups - MACD Calculations
  641.  
  642. MACDfastMA = 12
  643. MACDslowMA = 26
  644. MACDsignalSmooth = 9
  645.  
  646.  
  647. MACDLine = ema(close, MACDfastMA) - ema(close, MACDslowMA)
  648.  
  649. SignalLine = ema(MACDLine, MACDsignalSmooth)
  650.  
  651. MACDHistogram = MACDLine - SignalLine
  652.  
  653.  
  654. // Momentum Setups - MACD- Background Color Change Condition
  655.  
  656. MACDHistogramCross = MACDHistogram > 0 ? 1 : 0
  657.  
  658. MACDLineOverZero = MACDLine > 0 ? 1 : 0
  659.  
  660. MACDLineOverZeroandHistogramCross = MACDHistogramCross and MACDLineOverZero ? 1 : 0
  661.  
  662. MACDLineUnderZeroandHistogramCross = not MACDHistogramCross and not MACDLineOverZero ? 1 : 0
  663.  
  664.  
  665. // Momentum Setups - Top Dog Trading - Mom Dad Calculations
  666.  
  667. TopDog_Fast_MA = 5
  668. TopDog_Slow_MA = 20
  669. TopDog_Sig = 30
  670.  
  671.  
  672. TopDogMom = ema(close, TopDog_Fast_MA) - ema(close, TopDog_Slow_MA)
  673.  
  674. TopDogDad = ema(TopDogMom, TopDog_Sig)
  675.  
  676. // Momentum Setups - Top Dog Dad - Background Color Change Condition
  677.  
  678. TopDogDadDirection = TopDogDad > TopDogDad[1] ? 1 : 0
  679.  
  680. TopDogMomOverZero = TopDogMom > 0 ? 1 : 0
  681.  
  682. TopDogDadDirectandMomOverZero = TopDogDadDirection and TopDogMomOverZero ? 1 : 0
  683.  
  684. TopDogDadDirectandMomUnderZero = not TopDogDadDirection and not TopDogMomOverZero ? 1 : 0
  685.  
  686.  
  687. ////// Momentum Setups - Trend Barmeter Calculations //////
  688.  
  689. // UCS_Trend / Trend Candles Trend Barmeter Calculations
  690.  
  691. //UCS_Trend by ucsgears copy Trend Candles
  692. //Interpretation of TTM Trend bars. It is really close to the actual.
  693.  
  694. haclose = ohlc4
  695. haopen = 0.0
  696. haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2
  697. //hahigh = max(high, max(haopen, haclose))
  698. //halow = min(low, min(haopen, haclose))
  699.  
  700. ccolor = haclose - haopen > 0 ? 1 : 0
  701.  
  702. inside6 = haopen <= max(haopen[6], haclose[6]) and haopen >= min(haopen[6], haclose[6]) and
  703. haclose <= max(haopen[6], haclose[6]) and haclose >= min(haopen[6], haclose[6]) ?
  704. 1 : 0
  705.  
  706. inside5 = haopen <= max(haopen[5], haclose[5]) and haopen >= min(haopen[5], haclose[5]) and
  707. haclose <= max(haopen[5], haclose[5]) and haclose >= min(haopen[5], haclose[5]) ?
  708. 1 : 0
  709.  
  710. inside4 = haopen <= max(haopen[4], haclose[4]) and haopen >= min(haopen[4], haclose[4]) and
  711. haclose <= max(haopen[4], haclose[4]) and haclose >= min(haopen[4], haclose[4]) ?
  712. 1 : 0
  713.  
  714. inside3 = haopen <= max(haopen[3], haclose[3]) and haopen >= min(haopen[3], haclose[3]) and
  715. haclose <= max(haopen[3], haclose[3]) and haclose >= min(haopen[3], haclose[3]) ?
  716. 1 : 0
  717.  
  718. inside2 = haopen <= max(haopen[2], haclose[2]) and haopen >= min(haopen[2], haclose[2]) and
  719. haclose <= max(haopen[2], haclose[2]) and haclose >= min(haopen[2], haclose[2]) ?
  720. 1 : 0
  721.  
  722. inside1 = haopen <= max(haopen[1], haclose[1]) and haopen >= min(haopen[1], haclose[1]) and
  723. haclose <= max(haopen[1], haclose[1]) and haclose >= min(haopen[1], haclose[1]) ?
  724. 1 : 0
  725.  
  726.  
  727. colorvalue = inside6 ? ccolor[6] : inside5 ? ccolor[5] : inside4 ? ccolor[4] :
  728. inside3 ? ccolor[3] : inside2 ? ccolor[2] : inside1 ? ccolor[1] : ccolor
  729.  
  730.  
  731. // barcolor(Trend_Candle_Color , title = "Trend Candles")
  732. // barcolor(ShowTrendCandles? Trend_Candle_Color : na, title = "Trend Candles")
  733.  
  734.  
  735. // Momentum Setups - RSI 5 Trend Barmeter Calculations
  736.  
  737. RSI5 = rsi(close, 5)
  738.  
  739. RSI5Above50 = RSI5 > 50 ? 1 : 0
  740.  
  741.  
  742. // Trend Barmeter
  743.  
  744.  
  745. TrendBarMACross = MSMACrossover ? 1 : 0
  746.  
  747. TrendBarDadDirection = TopDogDadDirection ? 1 : 0
  748.  
  749. TrendBarMACD = MACDHistogramCross ? 1 : 0
  750.  
  751. TrendBarRSI5 = RSI5Above50 ? 1 : 0
  752.  
  753. TrendBarTrend_Candle = colorvalue ? 1 : 0
  754.  
  755.  
  756. TriggerUp = close > TriggerMA and close > open ? 1 : 0
  757. TriggerDown = close < TriggerMA and close < open ? 1 : 0
  758.  
  759. // TriggerUp = ((open - ohlc4) < TriggerMA) and close >= TriggerMA and close > open ? 1 : 0
  760. // TriggerDown = ((open + ohlc4) > TriggerMA) and close <= TriggerMA and close < open ? 1 : 0
  761.  
  762.  
  763. TrendBarPositive = (TrendBarMACD and TrendBarRSI5) or
  764. (TrendBarMACD and TrendBarTrend_Candle) or
  765. (TrendBarRSI5 and TrendBarTrend_Candle) ? 1 : 0
  766.  
  767. TrendBarNegative = (not TrendBarMACD and not TrendBarRSI5) or
  768. (not TrendBarMACD and not TrendBarTrend_Candle) or
  769. (not TrendBarRSI5 and not TrendBarTrend_Candle) ? 1 : 0
  770.  
  771.  
  772.  
  773. /////////////////////////////////////////////////////////////////////////////////////////////////
  774.  
  775.  
  776. KMainStochasticBelowMSOBThresholdUT = KStandardStoch < MSOBThresholdUT ? 1 : 0 // 80 Up Trend
  777.  
  778. KMainStochasticAboveMSOSThresholdUT = KStandardStoch > MSOSThresholdUT ? 1 : 0 // 20 Up Trend
  779.  
  780.  
  781. KMainStochasticBelowMSOBThresholdDT = KStandardStoch < MSOBThresholdDT ? 1 : 0 // 80 Down Trend
  782.  
  783. KMainStochasticAboveMSOSThresholdDT = KStandardStoch > MSOSThresholdDT ? 1 : 0 // 20 Down Trend
  784.  
  785.  
  786.  
  787. KMainStochasticAbove20 = KStandardStoch > 20 ? 1 : 0
  788.  
  789. KMainStochasticBelow80 = KStandardStoch < 80 ? 1 : 0
  790.  
  791. KAboveDMainStochastic = KStandardStoch > DStandardStoch ? 1 : 0
  792.  
  793.  
  794. LongMomentumTradeCondition = MSMACrossover and KMainStochasticAboveMSOSThresholdUT and KMainStochasticBelowMSOBThresholdUT and KAboveDMainStochastic and TriggerUp and TrendBarPositive ? 1 : 0
  795.  
  796. ShortMomentumTradeCondition = not MSMACrossover and KMainStochasticAboveMSOSThresholdDT and KMainStochasticBelowMSOBThresholdDT and not KAboveDMainStochastic and TriggerDown and TrendBarNegative ? 1 : 0
  797.  
  798.  
  799. LongMomentumTradeConditionTrigger = MSFilterType=="N/A" ? LongMomentumTradeCondition : MSFilterType=="Filter X" ? FilterX and LongMomentumTradeCondition : MSFilterType=="Trend Filter" ? TrendFilterPlus and LongMomentumTradeCondition : MSFilterType=="Filter X + Trend Filter" ? FilterX and TrendFilterPlus and LongMomentumTradeCondition : na
  800.  
  801. ShortMomentumTradeConditionTrigger = MSFilterType=="N/A" ? ShortMomentumTradeCondition : MSFilterType=="Filter X" ? not FilterX and ShortMomentumTradeCondition : MSFilterType=="Trend Filter" ? TrendFilterMinus and ShortMomentumTradeCondition : MSFilterType=="Filter X + Trend Filter" ? not FilterX and TrendFilterMinus and ShortMomentumTradeCondition : na
  802.  
  803.  
  804. /////////////////////////////////////////////////////////////////////////////////////////////////
  805.  
  806.  
  807. // Momentum Setups - Filter Calculations
  808.  
  809. MSFilter1 = MSLookBackFilterLength >= 1 ? 1 : 1
  810. MSFilter2 = MSLookBackFilterLength >= 2 ? 2 : 1
  811. MSFilter3 = MSLookBackFilterLength >= 3 ? 3 : 1
  812. MSFilter4 = MSLookBackFilterLength >= 4 ? 4 : 1
  813. MSFilter5 = MSLookBackFilterLength >= 5 ? 5 : 1
  814. MSFilter6 = MSLookBackFilterLength >= 6 ? 6 : 1
  815. MSFilter7 = MSLookBackFilterLength >= 7 ? 7 : 1
  816. MSFilter8 = MSLookBackFilterLength >= 8 ? 8 : 1
  817. MSFilter9 = MSLookBackFilterLength >= 9 ? 9 : 1
  818. MSFilter10 = MSLookBackFilterLength >= 10 ? 10 : 1
  819.  
  820.  
  821. LongTradeConditionMomentumStrategy = LongMomentumTradeConditionTrigger and
  822. not(LongMomentumTradeConditionTrigger[MSFilter1] or
  823. LongMomentumTradeConditionTrigger[MSFilter2] or
  824. LongMomentumTradeConditionTrigger[MSFilter3] or
  825. LongMomentumTradeConditionTrigger[MSFilter4] or
  826. LongMomentumTradeConditionTrigger[MSFilter5] or
  827. LongMomentumTradeConditionTrigger[MSFilter6] or
  828. LongMomentumTradeConditionTrigger[MSFilter7] or
  829. LongMomentumTradeConditionTrigger[MSFilter8] or
  830. LongMomentumTradeConditionTrigger[MSFilter9] or
  831. LongMomentumTradeConditionTrigger[MSFilter10]) ? 1 : 0
  832.  
  833.  
  834. ShortTradeConditionMomentumStrategy = ShortMomentumTradeConditionTrigger and
  835. not(ShortMomentumTradeConditionTrigger[1] or
  836. ShortMomentumTradeConditionTrigger[MSFilter2] or
  837. ShortMomentumTradeConditionTrigger[MSFilter3] or
  838. ShortMomentumTradeConditionTrigger[MSFilter4] or
  839. ShortMomentumTradeConditionTrigger[MSFilter5] or
  840. ShortMomentumTradeConditionTrigger[MSFilter6] or
  841. ShortMomentumTradeConditionTrigger[MSFilter7] or
  842. ShortMomentumTradeConditionTrigger[MSFilter8] or
  843. ShortMomentumTradeConditionTrigger[MSFilter9] or
  844. ShortMomentumTradeConditionTrigger[MSFilter10]) ? 1 : 0
  845.  
  846.  
  847. // Momentum Setups - Plots
  848.  
  849. plotshape(title='Momentum Setup - Long - Small Triangle', series=ShowMomentumSetups and MSPointerSizeIn=="Small"? LongTradeConditionMomentumStrategy : na, style=shape.triangleup, color=lime, transp=MSTransp, size=size.small, location=location.belowbar)
  850. plotshape(title='Momentum Setup - Short - Small Triangle', series=ShowMomentumSetups and MSPointerSizeIn=="Small"? ShortTradeConditionMomentumStrategy : na, style=shape.triangledown, color=red, transp=MSTransp, size=size.small, location=location.abovebar)
  851.  
  852. plotshape(title='Momentum Setup - Long - Large Triangle', series=ShowMomentumSetups and MSPointerSizeIn=="Large"? LongTradeConditionMomentumStrategy : na, style=shape.triangleup, color=lime, transp=MSTransp, size=size.normal, location=location.belowbar)
  853. plotshape(title='Momentum Setup - Short - Large Triangle', series=ShowMomentumSetups and MSPointerSizeIn=="Large"? ShortTradeConditionMomentumStrategy : na, style=shape.triangledown, color=red, transp=MSTransp, size=size.normal, location=location.abovebar)
  854.  
  855. // Momentum Setups - Alternative Plots
  856.  
  857. // plotshape(title='Momentum Setup - Long', series=ShowMomentumSetups ? LongTradeConditionMomentumStrategy : na, text="M\nS", style=shape.triangleup, color=lime, transp=MSTransp, size=size.small, location=location.belowbar, textcolor=color(lime, 10))
  858. // plotshape(title='Momentum Setup - Short', series=ShowMomentumSetups ? ShortTradeConditionMomentumStrategy : na, text="M\nS", style=shape.triangledown, color=red, transp=MSTransp, size=size.small, location=location.abovebar, textcolor=color(red, 10))
  859.  
  860. // plotshape(title='Momentum Setup - Long', series=ShowMomentumSetups ? LongTradeConditionMomentumStrategy : na, text="M\nS", style=shape.labelup, color=lime, transp=MSTransp, size=size.tiny, location=location.belowbar, textcolor=#00755EFA)
  861. // plotshape(title='Momentum Setup - Short', series=ShowMomentumSetups ? ShortTradeConditionMomentumStrategy : na, text="M\nS", style=shape.labeldown, color=red, transp=MSTransp, size=size.tiny, location=location.abovebar, textcolor=#75000CFA)
  862.  
  863. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  864.  
  865. // Alerts - RSI OB/OS Volume Climax
  866.  
  867. alertcondition(RSIOBClimax, title='Alert - RSI OB Vol Climax', message='RSI Over Bought Volume Climax')
  868. alertcondition(RSIOSClimax, title='Alert - RSI OS Vol Climax', message='RSI Over Sold Volume Climax')
  869.  
  870. // Alerts - Market Cipher / Wave Trend
  871.  
  872. alertcondition(SmallGreenDiamond, title='Alert - Small Green Diamond', message='Small Green Diamond - Alert - Market Cipher / Wave Trend')
  873. alertcondition(SmallRedDiamond, title='Alert - Small Red Diamond', message='Alert - Small Red Diamond - Alert - Market Cipher / Wave Trend')
  874.  
  875. alertcondition(BigRedDiamond, title='Alert - Big Red Diamond / Blood Diamond', message='Big Red Diamond / Blood Diamond - Alert - Market Cipher / Wave Trend')
  876. alertcondition(BigGreenDiamond, title='Alert - Big Green Diamond', message='Big Green Diamond - Alert - Market Cipher / Wave Trend')
  877.  
  878. alertcondition(YellowCross, title='Alert - Yellow Cross', message='Yellow Cross - Alert - Market Cipher / Wave Trend')
  879.  
  880. alertcondition(BlueTriangleUp, title='Alert - Blue Triangle Up', message='Blue Triangle Up - T Lines Have Crossed Over 15 EMA - Alert - Market Cipher / Wave Trend')
  881. alertcondition(BlueTriangleDown, title='Alert - Blue Triangle Down', message='Blue Triangle Down - T Lines Have Crossed Under 15 EMA - Alert - Market Cipher / Wave Trend')
  882.  
  883. // Alerts & Conditions - Momentum Setup
  884.  
  885. alertcondition(LongTradeConditionMomentumStrategy, title='Alert - Momentum Setup - Long Condition', message='Long Condition - Momentum Setup')
  886. alertcondition(ShortTradeConditionMomentumStrategy, title='Alert - Momentum Setup - Short Condition', message='Short Condition - Momentum Setup')
  887.  
  888. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment