Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- plot(close)
- study(title="D_Market Cipher A", shorttitle="D_WEACipher_A++", overlay=true)
- // PARAMETERS {
- // WaveTrend Overbought & Oversold lines
- obLevel = input(53, "WT Overbought Level 1")
- obLevel2 = input(60, "WT Overbought Level 2")
- osLevel = input(-53, "WT Oversold Level 1")
- osLevel2 = input(-60, "WT Oversold Level 2")
- //EMA Ribbon
- showRibbon = input(true, "Show Ribbon")
- ema_1 = input(5)
- ema_2 = input(11)
- ema_3 = input(15)
- ema_4 = input(18)
- ema_5 = input(21)
- ema_6 = input(24)
- ema_7 = input(28)
- ema_8 = input(34)
- // }
- // CALCULATE INDICATORS {
- //EMA Ribbon
- ema1_ = ema(close, ema_1)
- ema2_ = ema(close, ema_2)
- ema3_ = ema(close, ema_3)
- ema4_ = ema(close, ema_4)
- ema5_ = ema(close, ema_5)
- ema6_ = ema(close, ema_6)
- ema7_ = ema(close, ema_7)
- ema8_ = ema(close, ema_8)
- // RSI
- up = rma(max(change(close), 0), 14)
- down = rma(-min(change(close), 0), 14)
- rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
- // WT
- n1 = input(7, "WT Channel Length")
- n2 = input(12, "WT Average Length")
- ap = input(ohlc4)
- esa = ema(ap, n1)
- de = ema(abs(ap - esa), n1)
- ci = (ap - esa) / (0.015 * de)
- tci = ema(ci, n2)
- wt1 = tci
- wt2 = sma(wt1, 3)
- vwap_area = wt1 - wt2
- // WaveTrend Conditions
- WTCross = cross(wt1, wt2)
- WTCrossUp = wt2 - wt1 <= 0
- WTCrossDown = wt2 - wt1 >= 0
- WTOverSold = wt2 <= osLevel2
- WTOverBought = wt2 >= obLevel2
- // Signals
- longEma = crossover(ema2_, ema8_)
- redCross = crossunder(ema1_, ema2_)
- blueTriangle = crossover(ema2_, ema3_)
- redDiamond = WTCross and WTCrossDown
- yellowCross = redDiamond and rsi <= 30 and wt2 <= osLevel
- bloodDiamond = redDiamond and redCross
- shortEma = crossover(ema8_, ema2_)
- // } CALCULATE INDICATORS
- // DRAW {
- // EMA Ribbon
- colorEma = ema8_ < ema2_ ? green : red
- plot(ema1_, color=showRibbon ? #265aa6 : na, linewidth=2, transp=50, title="EMA 1")
- plot(ema2_, color=showRibbon ? #265aa6 : na, linewidth=2, transp=50, title="EMA 2")
- plot(ema3_, color=showRibbon ? #1976d2 : na, linewidth=2, transp=50, title="EMA 3")
- plot(ema4_, color=showRibbon ? #1976d2 : na, linewidth=2, transp=50, title="EMA 4")
- plot(ema5_, color=showRibbon ? #7fb3ff : na, linewidth=2, transp=50, title="EMA 5")
- plot(ema6_, color=showRibbon ? #7fb3ff : na, linewidth=2, transp=50, title="EMA 6")
- plot(ema7_, color=showRibbon ? #bbdefb : na, linewidth=2, transp=50, title="EMA 7")
- plot(ema8_, color=showRibbon ? #bbdefb : na, linewidth=2, transp=50, title="EMA 8")
- plot(ema8_, color=showRibbon ? na : colorEma, linewidth=2, transp=50, title="EMA 8")
- // SHAPES
- plotshape(longEma, style=shape.circle, color=#00ff00, transp=50, location=location.abovebar, size=size.tiny, title="Long EMA Signal")
- plotshape(shortEma, style=shape.circle, color=#ff0000, transp=50, location=location.abovebar, size=size.tiny, title="Short EMA Signal")
- plotshape(redCross, style=shape.xcross, color=#ff0000, transp=50, location=location.abovebar, size=size.tiny, title="Red cross")
- plotshape(blueTriangle, style=shape.triangleup, color=#0064ff, transp=50, location=location.abovebar, size=size.small, title="Blue Triangle")
- plotshape(redDiamond, style=shape.diamond, color=#ff0000, location=location.abovebar, size=size.tiny, title="Red Diamond", transp=25)
- plotshape(bloodDiamond, style=shape.diamond, color=#ff0000, location=location.abovebar, size=size.small, title="Blood Diamond", transp=15)
- plotshape(yellowCross, style=shape.xcross, color=yellow, location=location.abovebar, size=size.small, title="Yellow Cross", transp=25)
- // } DRAW
- // ALERTS {
- alertcondition(redDiamond != 0, "Red Diamond", "Red Diamond")
- alertcondition(bloodDiamond != 0, "Blood Diamond", "Blood Diamond")
- alertcondition(yellowCross != 0, "YellowX", "YellowX")
- alertcondition(redCross != 0, "RedX", "RedX")
- alertcondition(longEma != 0, "Longema", "Longema")
- alertcondition(blueTriangle != 0, "Bluetriangle", "Bluetriangle")
- //******************************************************************************************************************************************************************************************************
- src = close
- useCurrentRes = input(true, title="Use Current Chart Resolution?")
- resCustom = input(title="Use Different Timeframe? Uncheck Box Above", defval="D")
- len = input(20, title="Moving Average Length - LookBack Period")
- //period = input(defval=7, title="Tilson T3 Period", minval=1)
- factorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0)
- 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")
- spc=input(false, title="Show Price Crossing 1st Mov Avg - Highlight Bar?")
- cc = input(true,title="Change Color Based On Direction?")
- smoothe = input(2, minval=1, maxval=10, title="Color Smoothing - Setting 1 = No Smoothing")
- doma2 = input(false, title="Optional 2nd Moving Average")
- spc2=input(false, title="Show Price Crossing 2nd Mov Avg?")
- len2 = input(50, title="Moving Average Length - Optional 2nd MA")
- sfactorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0)
- 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")
- cc2 = input(true,title="Change Color Based On Direction 2nd MA?")
- warn = input(false, title="***You Can Turn On The Show Dots Parameter Below Without Plotting 2nd MA to See Crosses***")
- warn2 = input(false, title="***If Using Cross Feature W/O Plotting 2ndMA - Make Sure 2ndMA Parameters are Set Correctly***")
- sd = input(false, title="Show Dots on Cross of Both MA's")
- res = useCurrentRes ? period : resCustom
- //hull ma definition
- hullma = wma(2*wma(src, len/2)-wma(src, len), round(sqrt(len)))
- //TEMA definition
- ema1 = ema(src, len)
- ema2 = ema(ema1, len)
- ema3 = ema(ema2, len)
- tema = 3 * (ema1 - ema2) + ema3
- //Tilson T3
- factor = factorT3 *.10
- gd(src, len, factor) => ema(src, len) * (1 + factor) - ema(ema(src, len), len) * factor
- t3(src, len, factor) => gd(gd(gd(src, len, factor), len, factor), len, factor)
- tilT3 = t3(src, len, factor)
- 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
- //2nd Ma - hull ma definition
- hullma2 = wma(2*wma(src, len2/2)-wma(src, len2), round(sqrt(len2)))
- //2nd MA TEMA definition
- sema1 = ema(src, len2)
- sema2 = ema(sema1, len2)
- sema3 = ema(sema2, len2)
- stema = 3 * (sema1 - sema2) + sema3
- //2nd MA Tilson T3
- sfactor = sfactorT3 *.10
- sgd(src, len2, sfactor) => ema(src, len2) * (1 + sfactor) - ema(ema(src, len2), len2) * sfactor
- st3(src, len2, sfactor) => sgd(sgd(gd(src, len2, sfactor), len2, sfactor), len2, sfactor)
- stilT3 = st3(src, len2, sfactor)
- 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
- out = avg
- out_two = avg2
- out1 = security(tickerid, res, out)
- out2 = security(tickerid, res, out_two)
- //Formula for Price Crossing Moving Average #1
- cr_up = open < out1 and close > out1
- cr_Down = open > out1 and close < out1
- //Formula for Price Crossing Moving Average #2
- cr_up2 = open < out2 and close > out2
- cr_Down2 = open > out2 and close < out2
- //barcolor Criteria for Price Crossing Moving Average #1
- iscrossUp() => cr_up
- iscrossDown() => cr_Down
- //barcolor Criteria for Price Crossing Moving Average #2
- iscrossUp2() => cr_up2
- iscrossDown2() => cr_Down2
- ma_up = out1 >= out1[smoothe]
- ma_down = out1 < out1[smoothe]
- col = cc ? ma_up ? lime : ma_down ? red : aqua : aqua
- col2 = cc2 ? ma_up ? lime : ma_down ? red : aqua : white
- circleYPosition = out2
- plot(out1, title="Multi-Timeframe Moving Avg", linewidth=13, color = col)
- plot(doma2 and out2 ? out2 : na, title="2nd Multi-TimeFrame Moving Average", style=circles, linewidth=4, color=col2)
- plot(sd and cross(out1, out2) ? circleYPosition : na,style=cross, linewidth=15, color=aqua)
- //barcolor Plot for Price Crossing Moving Average #1
- barcolor(spc and iscrossUp() ? (iscrossUp() ? yellow : na) : na)
- barcolor(spc and iscrossDown() ? (iscrossDown() ? yellow : na) : na)
- //barcolor Plot for Price Crossing Moving Average #2
- barcolor(spc2 and iscrossUp2() ? (iscrossUp2() ? yellow : na) : na)
- barcolor(spc2 and iscrossDown2() ? (iscrossDown2() ? yellow : na) : na)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement