I'm using pine editor for coding in TradingView, I 'm using 3 supertrends, now for a downtrend, 1st supertrend gives Sell[Red in color] signal and starts with red line downwards, after that 2nd supertrend gives Sell [Orande in color] signal and starts with red line downwards, similar process for 3rd supertrend[purple color], over here if all the supertrends are giving Sell signal, then I need to show one big parent SELL sign indicating that all the SELL conditions are satisfied, now if one of the signal turns green indicating Buy signal and later on it turns red i.e. SEll signal, again a parent SELL sign should be visible on the chart. this gives a hint that I need to short from here.
I have attached screenshot could you please help me with the code.
Here is the code for your reference
//@version=4
study("ST", overlay = true, format=format.price, precision=2, resolution="")
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=1.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=false)
buyBool = false
sellBool = false
atr2 = sma(tr, Periods)
atr = changeATR ? atr(Periods) : atr2
up = src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn = src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], 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=1, color=color.green)
buySignal = trend == 1 and trend[1] == -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=1, color=color.red)
sellSignal = trend == -1 and trend[1] == 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[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
Periods1 = input( 11, title="atr1 Period", type=input.integer)
src1 = input( hl2, title="Source")
Multiplier1 = input( 2.0, title="atr1 Multiplier1", type=input.float, step=0.1)
changeatr11 = input( true, title="Change atr1 Calculation Method ?", type=input.bool)
showsignals1 = input( true, title="Show Buy/Sell Signals ?", type=input.bool)
highlighting1 = input(false, title="Highlighter On/Off ?", type=input.bool)
buyBool1 = false
sellBool1 = false
atr121 = sma(tr, Periods1)
atr1 = changeatr11 ? atr(Periods1) : atr121
up123 = src1-(Multiplier1*atr1)
up1231 = nz(up123[1],up123)
up123 := close[1] > up1231 ? max(up123,up1231) : up123
dn123 = src1+(Multiplier1*atr1)
dn1231 = nz(dn123[1], dn123)
dn123 := close[1] < dn1231 ? min(dn123, dn1231) : dn123
trend1 = 1
trend1 := nz(trend1[1], trend1)
trend1 := trend1 == -1 and close > dn1231 ? 1 : trend1 == 1 and close < up1231 ? -1 : trend1
up123Plot1 = plot(trend1 == 1 ? up123 : na, title="up123 trend1", style=plot.style_linebr, linewidth=1, color=color.green)
buySignal1 = trend1 == 1 and trend1[1] == -1
plotshape(buySignal1 ? up123 : na, title="up123trend1 Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.orange, transp=0)
plotshape(buySignal1 and showsignals1 ? up123 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.orange, textcolor=color.white, transp=0)
dn123Plot = plot(trend1 == 1 ? na : dn123, title="Down trend1", style=plot.style_linebr, linewidth=1, color=color.red)
sellSignal1 = trend1 == -1 and trend1[1] == 1
plotshape(sellSignal1 ? dn123 : na, title="Downtrend1 Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.orange, transp=0)
plotshape(sellSignal1 and showsignals1 ? dn123 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.orange, 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, up123Plot1, title="up123trend1 Highligter", color=longFillColor1)
fill(mPlot1, dn123Plot, title="Downtrend1 Highligter", color=shortFillColor1)
alertcondition(buySignal1, title="Sup123ertrend1 Buy", message="Sup123ertrend1 Buy!")
alertcondition(sellSignal1, title="Sup123ertrend1 Sell", message="Sup123ertrend1 Sell!")
changeCond1 = trend1 != trend1[1]
alertcondition(changeCond1, title="Sup123ertrend1 Direction Change", message="Sup123ertrend1 has changed direction!")
Script could not be translated from: |B|up := close[1] >
- Bjorn Mistiaen