quocdn000

ichimoku-supertrend Quoc Le

Long
OANDA:XAUUSD   Gold Spot / U.S. Dollar
// © Maihoangtri

//@version=4
study("Ichimoku QL", shorttitle="Ichi Quoc Le",overlay=true)
Midpoint(len)=>avg(highest(len),lowest(len))
Offset=input(26,title="Displacement")
//-------------------------------------------------------------------------------------------------
//Draw Tenkan line
TK_lenghth=input(9,title="Tenkan leghth",minval=1)
TK=Midpoint(TK_lenghth)
plot(TK,title="Tenkan line",color=#002aff,linewidth=1)
//-------------------------------------------------------------------------------------------------
//Draw Kijun line
KJ_lenghth=input(26,title="Kijun leghth",minval=1)
KJ=Midpoint(KJ_lenghth)
plot(KJ,title="Kijun line",color=#ff4000,linewidth=1)
//-------------------------------------------------------------------------------------------------
//Draw Tenkan2 line
TK2_lenghth=input(65,title="Tenkan2 leghth",minval=1)
TK2=Midpoint(TK2_lenghth)
plot(TK2,title="Tenkan2 line",color=#002aff,linewidth=1)
//-------------------------------------------------------------------------------------------------
//Draw Kijun2 line
KJ2_lenghth=input(129,title="Kijun2 leghth",minval=1)
KJ2=Midpoint(KJ2_lenghth)
plot(KJ2,title="Kijun2 line",color=#ff4000,linewidth=1)
//-------------------------------------------------------------------------------------------------
//Draw Dagger 65
DG65_lenghth=input(65,title="Dagger 65 leghth",minval=1)
DG65=Midpoint(DG65_lenghth)
plot(DG65,title="Dagger 65 line",color=#ffa200,linewidth=2)
//-------------------------------------------------------------------------------------------------
//Draw Dagger 129
DG129_lenghth=input(129,title="Dagger 129 leghth",minval=1)
DG129=Midpoint(DG129_lenghth)
plot(DG129,title="Dagger 129 line",color=#6708c7,linewidth=2)
//-------------------------------------------------------------------------------------------------
//Chikou
CK = close
plot(CK,title="Chikou line",color=#283b57,linewidth=1,offset=-Offset)
//-------------------------------------------------------------------------------------------------
//Span A
SpanA=avg(TK,KJ)
//-------------------------------------------------------------------------------------------------
//Span B
SpanB_lenghth=input(52,title="Span B leghth",minval=1)
SpanB=Midpoint(SpanB_lenghth)
//-------------------------------------------------------------------------------------------------
//Span A2
SpanA2=avg(TK2,KJ2)
//-------------------------------------------------------------------------------------------------
//Span B2
SpanB2_lenghth=input(200,title="Span B2 leghth",minval=1)
SpanB2=Midpoint(SpanB2_lenghth)
//-------------------------------------------------------------------------------------------------
//Kumo Color
Kumo_color = SpanA>=SpanB ? color.new(color.green, 50): color.new(color.red, 50)
Kumo_line_color=SpanA>=SpanB ? color.new(color.green, 50): color.new(color.red, 50)
s1=plot(SpanA,title="Span A line",color=Kumo_line_color,linewidth=1,offset=Offset)
s2=plot(SpanB,title="Span B line",color=Kumo_line_color,linewidth=1,offset=Offset)
fill(s1,s2,title="Kumo Cloud Color",color=Kumo_color)
//-------------------------------------------------------------------------------------------------
//Kumo2 Color
Kumo2_color = SpanA2>=SpanB2 ? color.new(color.green, 50): color.new(color.red, 50)
Kumo2_line_color=SpanA2>=SpanB2 ? color.new(color.green, 50): color.new(color.red, 50)
s1a=plot(SpanA2,title="Span A2 line",color=Kumo2_line_color,linewidth=1,offset=Offset)
s2a=plot(SpanB2,title="Span B2 line",color=Kumo2_line_color,linewidth=1,offset=Offset)
fill(s1,s2,title="Kumo2 Cloud Color",color=Kumo2_color)
//-------------------------------------------------------------------------------------------------
// Tenkan & Kijun H1 for Breakout signal
donchian(len) => avg(lowest(len), highest(len))
TK_H1 = donchian(108)
KJ_H1 = donchian(204)
//-------------------------------------------------------------------------------------------------
//Draw Tekan & Kijun Vertical line
bgcolor(color=color.new(color.blue, 90), offset=-8,show_last=1,title= "TK vertical line")
bgcolor(color=color.new(color.red, 90), offset=-16,show_last=1,title= "KJ vertical line")
bgcolor(color=color.new(color.gray, 90), offset=-25,show_last=1,title= "Chikou vertical line")
//-------------------------------------------------------------------------------------------------
// Union Signal
Union_up=(TK>TK and KJ>KJ and TK==KJ) or (TK>TK and KJ>KJ and (TK-KJ)<=0.00004)
Union_down=(TK<TK and KJ<KJ and TK==KJ) or (TK<TK and KJ<KJ and (KJ-TK)<=0.00004)
Break_out=Union_up and TK_H1>TK_H1 and KJ_H1>KJ_H1 and DG65>DG65 and DG129>DG129 and TK_H1-KJ_H1<=0.00004
Break_down=Union_down and TK_H1<TK_H1 and KJ_H1<KJ_H1 and DG65<DG65 and DG129<DG129 and KJ_H1-TK_H1<=0.00004
plotchar(Union_up,char='⚔',location=location.abovebar, color=color.blue)
plotchar(Union_down,char='⚔',location=location.belowbar, color=color.blue)
plotchar(Break_out,char='💣',location=location.abovebar, color=color.blue)
plotchar(Break_down,char='💣',location=location.belowbar, color=color.blue)
//-------------------------------------------------------------------------------------------------
// Alert For Trading Signal
alertcondition(Union_up, title='Alert on Union Up', message='Union Up!')
alertcondition(Union_down, title='Alert on Union Down', message='Union Down!')
alertcondition(Break_out, title='Alert on Break out', message='Break out!')
alertcondition(Break_down, title='Alert on Break down', message='Break down!')
//-------------------------------------------------------------------------------------------------
// Plot Future Lines
TK_future1 = avg(highest(8),lowest(8))
TK_future2 = avg(highest(7),lowest(7))
TK_future3 = avg(highest(6),lowest(6))
TK_future4 = avg(highest(5),lowest(5))
TK_future5 = avg(highest(4),lowest(4))
TK_future6 = avg(highest(3),lowest(3))
TK_future7 = avg(highest(2),lowest(2))
TK_future8 = avg(highest(1),lowest(1))

KJ_future1 = avg(highest(16),lowest(16))
KJ_future2 = avg(highest(15),lowest(15))
KJ_future3 = avg(highest(14),lowest(14))
KJ_future4 = avg(highest(13),lowest(13))
KJ_future5 = avg(highest(12),lowest(12))
KJ_future6 = avg(highest(11),lowest(11))
KJ_future7 = avg(highest(10),lowest(10))
KJ_future8 = avg(highest(9),lowest(9))
//Future Daily Tenkan
plot(TK_future1, color=#002aff, linewidth=1, offset=1, show_last=1, style=plot.style_circles)
plot(TK_future2, color=#002aff, linewidth=1, offset=2, show_last=1, style=plot.style_circles)
plot(TK_future3, color=#002aff, linewidth=1, offset=3, show_last=1, style=plot.style_circles)
plot(TK_future4, color=#002aff, linewidth=1, offset=4, show_last=1, style=plot.style_circles)
plot(TK_future5, color=#002aff, linewidth=1, offset=5, show_last=1, style=plot.style_circles)
plot(TK_future6, color=#002aff, linewidth=1, offset=6, show_last=1, style=plot.style_circles)
plot(TK_future7, color=#002aff, linewidth=1, offset=7, show_last=1, style=plot.style_circles)
plot(TK_future8, color=#002aff, linewidth=1, offset=8, show_last=1, style=plot.style_circles)
//Future Daily Kijun
plot(KJ_future1, color=#ff4000, linewidth=1, offset=1, show_last=1, style=plot.style_circles)
plot(KJ_future2, color=#ff4000, linewidth=1, offset=2, show_last=1, style=plot.style_circles)
plot(KJ_future3, color=#ff4000, linewidth=1, offset=3, show_last=1, style=plot.style_circles)
plot(KJ_future4, color=#ff4000, linewidth=1, offset=4, show_last=1, style=plot.style_circles)
plot(KJ_future5, color=#ff4000, linewidth=1, offset=5, show_last=1, style=plot.style_circles)
plot(KJ_future6, color=#ff4000, linewidth=1, offset=6, show_last=1, style=plot.style_circles)
plot(KJ_future7, color=#ff4000, linewidth=1, offset=7, show_last=1, style=plot.style_circles)
plot(KJ_future8, color=#ff4000, linewidth=1, offset=8, show_last=1, style=plot.style_circles)

//-------------------------------------------------------------------------------------------------

//TRADING RULES
//Conversion Line and Baseline crossover with Laggin Span Filter
ConvBaseBuy = crossover(TK, KJ)
ConvBaseSell = crossunder(TK, KJ)

//Conversion Line and Baseline crossover with Kumo Cloud Filter
//Kumo Cloud Rule
idealbuy = (close>high) and TK>KJ and (close>SpanA and close>SpanB) and (low>SpanA and low>SpanB)
idealsell = (close<low) and TK<KJ and (close<SpanA and close<SpanB) and (high<SpanA and high<SpanB)

buymem = false
sellmem = false

buymem := idealbuy?true:idealsell?false:buymem
sellmem := idealsell?true:idealbuy?false:sellmem

longCond = idealbuy and not(buymem)
shortCond = idealsell and not(sellmem)

plotshape(series=longCond, text = "Ichi Buy", title="Ichi Buy", location=location.belowbar, style=shape.triangleup, color=color.lime, size=size.small)
plotshape(series=shortCond, text="Ichi Sell", title="Ichi Sell", location=location.abovebar, style=shape.triangledown, color=color.red, size=size.small)

//Cloud Rule
buycloud = crossover(SpanA, SpanB) and (low>SpanA and low>SpanB)
sellcloud = crossunder(SpanA, SpanB) and (high<SpanA and high<SpanB)

plotshape(series=buycloud, text = "Cloud Buy", title="Cloud Buy", location=location.belowbar, style=shape.triangleup, color=color.lime, size=size.small)
plotshape(series=sellcloud, text="Cloud Sell", title="Cloud Sell", location=location.abovebar, style=shape.triangledown, color=color.red, size=size.small)

alertcondition(longCond, title="Ichi Buy", message="Buy it like a snail")
alertcondition(shortCond, title="Icchi Sell", message="Sell it like a snail")
alertcondition(buycloud, title="Cloud Buy", message="I'm Goku")
alertcondition(sellcloud, title="Cloud Sell", message="Bulma took a ride and is now Falling")

//@version=4


Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up,up)
up := close > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn, dn)
dn := close < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend, trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.