Hello, would anyone be able to help. I was hoping to code an indicator that puts either a red (sell) or green (buy) marker above/below the candlesticks on the chart if the candle closes outside the Bollinger band and the next candle closes in the band via an engulfing candle (I define an engulfing candle as the body of the engulfing has a higher body high and a lower body low to that of the previous candle).
This indicator would be based off a standard 20SMA 2 standard deviation Bollinger band.
Please see attached link for a visual representation.
Many Regards
Joe
https://www.tradingview.com/x/qYkT2gNH/
JSParticipant
Veteran
Hi @jdh320
Here is the indicator…
S1=Average[20](Close) //SMA 20 periods
S2=Std[20](Close) // Standard Deviation 20 periods
S3=Close[1]>Open[1] and Open>Close[1] and Close<Open[1] //Bearish Engulfing
S4=Close[1]<Open[1] and Open<Close[1] and Close>Open[1] //Bullish Engulfing
If Close[1] Crosses Over S1[1] + 2*S2[1] and S3 then
DrawArrowDown(BarIndex,High+5*pipsize) Coloured(255,0,0)
EndIf
If Close[1] Crosses Under S1[1] - 2*S2[1] and S4 then
DrawArrowUp(BarIndex,Low-5*pipsize) Coloured(0,255,0)
EndIf
Return S1 as "SMA[20]" Style(Dottedline), S1+2*S2 as "BB-Up" Coloured(255,0,0), S1-2*S2 as "BB-Down" Coloured(0,255,0)
Ah thats great, thank you so much.
Many Regards
Joe