W2
W2
// Supertrend 1
Periods1 = input(title="ATR Period 1", type=input.integer, defval=10)
src1 = input(hl2, title="Source 1")
Multiplier1 = input(title="ATR Multiplier 1", type=input.float, step=0.1,
defval=3.0)
changeATR1 = input(title="Change ATR Calculation Method 1?", type=input.bool,
defval=true)
showsignals1 = input(title="Show Buy/Sell Signals 1?", type=input.bool,
defval=true)
highlighting1 = input(title="Highlighter On/Off 1?", type=input.bool, defval=true)
atr2_1 = sma(tr, Periods1)
atr1 = changeATR1 ? atr(Periods1) : atr2_1
up1 = src1 - (Multiplier1 * atr1)
up1_1 = nz(up1[1], up1)
up1 := close[1] > up1_1 ? max(up1, up1_1) : up1
dn1 = src1 + (Multiplier1 * atr1)
dn1_1 = nz(dn1[1], dn1)
dn1 := close[1] < dn1_1 ? min(dn1, dn1_1) : dn1
trend1 = 1
trend1 := nz(trend1[1], trend1)
trend1 := trend1 == -1 and close > dn1_1 ? 1 : trend1 == 1 and close < up1_1 ? -1 :
trend1
upPlot1 = plot(trend1 == 1 ? up1 : na, title="Up Trend 1", style=plot.style_linebr,
linewidth=2, color=color.green)
buySignal1 = trend1 == 1 and trend1[1] == -1
plotshape(buySignal1 ? up1 : na, title="UpTrend Begins 1",
location=location.absolute, style=shape.circle, size=size.tiny, color=color.green,
transp=0)
plotshape(buySignal1 and showsignals1 ? up1 : na, title="Buy 1", text="Buy",
location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green,
textcolor=color.white, transp=0)
dnPlot1 = plot(trend1 == 1 ? na : dn1, title="Down Trend 1",
style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal1 = trend1 == -1 and trend1[1] == 1
plotshape(sellSignal1 ? dn1 : na, title="DownTrend Begins 1",
location=location.absolute, style=shape.circle, size=size.tiny, color=color.red,
transp=0)
plotshape(sellSignal1 and showsignals1 ? dn1 : na, title="Sell 1", text="Sell",
location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red,
textcolor=color.white, transp=0)
mPlot1 = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor1 = highlighting1 ? (trend1 == 1 ? color.green : color.white) :
color.white
shortFillColor1 = highlighting1 ? (trend1 == -1 ? color.red : color.white) :
color.white
fill(mPlot1, upPlot1, title="UpTrend Highligter 1", color=longFillColor1)
fill(mPlot1, dnPlot1, title="DownTrend Highligter 1", color=shortFillColor1)
alertcondition(buySignal1, title="SuperTrend Buy 1", message="SuperTrend Buy 1!")
alertcondition(sellSignal1, title="SuperTrend Sell 1", message="SuperTrend Sell
1!")
changeCond1 = trend1 != trend1[1]
alertcondition(changeCond1, title="SuperTrend Direction Change 1",
message="SuperTrend 1 has changed direction!")
alertcondition(crossunder(close, up1), title="Price Crossed Down Up Trend 1",
message="Price crossed down the Up Trend 1 line")
alertcondition(crossover(close, dn1), title="Price Crossed Up Down Trend 1",
message="Price crossed up the Down Trend 1 line")
// Supertrend 2
Periods2 = input(title="ATR Period 2", type=input.integer, defval=10)
src2 = input(hl2, title="Source 2")
Multiplier2 = input(title="ATR Multiplier 2", type=input.float, step=0.1,
defval=3.0)
changeATR2 = input(title="Change ATR Calculation Method 2?", type=input.bool,
defval=true)
showsignals2 = input(title="Show Buy/Sell Signals 2?", type=input.bool,
defval=true)
highlighting2 = input(title="Highlighter On/Off 2?", type=input.bool, defval=true)
atr2_2 = sma(tr, Periods2)
atr2 = changeATR2 ? atr(Periods2) : atr2_2
up2 = src2 - (Multiplier2 * atr2)
up2_1 = nz(up2[1], up2)
up2 := close[1] > up2_1 ? max(up2, up2_1) : up2
dn2 = src2 + (Multiplier2 * atr2)
dn2_1 = nz(dn2[1], dn2)
dn2 := close[1] < dn2_1 ? min(dn2, dn2_1) : dn2
trend2 = 1
trend2 := nz(trend2[1], trend2)
trend2 := trend2 == -1 and close > dn2_1 ? 1 : trend2 == 1 and close < up2_1 ? -1 :
trend2
upPlot2 = plot(trend2 == 1 ? up2 : na, title="Up Trend 2", style=plot.style_linebr,
linewidth=2, color=color.green)
buySignal2 = trend2 == 1 and trend2[1] == -1
plotshape(buySignal2 ? up2 : na, title="UpTrend Begins 2",
location=location.absolute, style=shape.circle, size=size.tiny, color=color.green,
transp=0)
plotshape(buySignal2 and showsignals2 ? up2 : na, title="Buy 2", text="Buy",
location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green,
textcolor=color.white, transp=0)
dnPlot2 = plot(trend2 == 1 ? na : dn2, title="Down Trend 2",
style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal2 = trend2 == -1 and trend2[1] == 1
plotshape(sellSignal2 ? dn2 : na, title="DownTrend Begins 2",
location=location.absolute, style=shape.circle, size=size.tiny, color=color.red,
transp=0)
plotshape(sellSignal2 and showsignals2 ? dn2 : na, title="Sell 2", text="Sell",
location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red,
textcolor=color.white, transp=0)
mPlot2 = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor2 = highlighting2 ? (trend2 == 1 ? color.green : color.white) :
color.white
shortFillColor2 = highlighting2 ? (trend2 == -1 ? color.red : color.white) :
color.white
fill(mPlot2, upPlot2, title="UpTrend Highligter 2", color=longFillColor2)
fill(mPlot2, dnPlot2, title="DownTrend Highligter 2", color=shortFillColor2)
alertcondition(buySignal2, title="SuperTrend Buy 2", message="SuperTrend Buy 2!")
alertcondition(sellSignal2, title="SuperTrend Sell 2", message="SuperTrend Sell
2!")
changeCond2 = trend2 != trend2[1]
alertcondition(changeCond2, title="SuperTrend Direction Change 2",
message="SuperTrend 2 has changed direction!")
alertcondition(crossunder(close, up2), title="Price Crossed Down Up Trend 2",
message="Price crossed down the Up Trend 2 line")
alertcondition(crossover(close, dn2), title="Price Crossed Up Down Trend 2",
message="Price crossed up the Down Trend 2 line")
// Supertrend 3
Periods3 = input(title="ATR Period 3", type=input.integer, defval=10)
src3 = input(hl2, title="Source 3")
Multiplier3 = input(title="ATR Multiplier 3", type=input.float, step=0.1,
defval=3.0)
changeATR3 = input(title="Change ATR Calculation Method 3?", type=input.bool,
defval=true)
showsignals3 = input(title="Show Buy/Sell Signals 3?", type=input.bool,
defval=true)
highlighting3 = input(title="Highlighter On/Off 3?", type=input.bool, defval=true)
atr2_3 = sma(tr, Periods3)
atr3 = changeATR3 ? atr(Periods3) : atr2_3
up3 = src3 - (Multiplier3 * atr3)
up3_1 = nz(up3[1], up3)
up3 := close[1] > up3_1 ? max(up3, up3_1) : up3
dn3 = src3 + (Multiplier3 * atr3)
dn3_1 = nz(dn3[1], dn3)
dn3 := close[1] < dn3_1 ? min(dn3, dn3_1) : dn3
trend3 = 1
trend3 := nz(trend3[1], trend3)
trend3 := trend3 == -1 and close > dn3_1 ? 1 : trend3 == 1 and close < up3_1 ? -1 :
trend3
upPlot3 = plot(trend3 == 1 ? up3 : na, title="Up Trend 3", style=plot.style_linebr,
linewidth=2, color=color.green)
buySignal3 = trend3 == 1 and trend3[1] == -1
plotshape(buySignal3 ? up3 : na, title="UpTrend Begins 3",
location=location.absolute, style=shape.circle, size=size.tiny, color=color.green,
transp=0)
plotshape(buySignal3 and showsignals3 ? up3 : na, title="Buy 3", text="Buy",
location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green,
textcolor=color.white, transp=0)
dnPlot3 = plot(trend3 == 1 ? na : dn3, title="Down Trend 3",
style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal3 = trend3 == -1 and trend3[1] == 1
plotshape(sellSignal3 ? dn3 : na, title="DownTrend Begins 3",
location=location.absolute, style=shape.circle, size=size.tiny, color=color.red,
transp=0)
plotshape(sellSignal3 and showsignals3 ? dn3 : na, title="Sell 3", text="Sell",
location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red,
textcolor=color.white, transp=0)
mPlot3 = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor3 = highlighting3 ? (trend3 == 1 ? color.green : color.white) :
color.white
shortFillColor3 = highlighting3 ? (trend3 == -1 ? color.red : color.white) :
color.white
fill(mPlot3, upPlot3, title="UpTrend Highligter 3", color=longFillColor3)
fill(mPlot3, dnPlot3, title="DownTrend Highligter 3", color=shortFillColor3)
alertcondition(buySignal3, title="SuperTrend Buy 3", message="SuperTrend Buy 3!")
alertcondition(sellSignal3, title="SuperTrend Sell 3", message="SuperTrend Sell
3!")
changeCond3 = trend3 != trend3[1]
alertcondition(changeCond3, title="SuperTrend Direction Change 3",
message="SuperTrend 3 has changed direction!")
alertcondition(crossunder(close, up3), title="Price Crossed Down Up Trend 3",
message="Price crossed down the Up Trend 3 line")
alertcondition(crossover(close, dn3), title="Price Crossed Up Down Trend 3",
message="Price crossed up the Down Trend 3 line")