Ravi teja sreevatsav's consecutive candle
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RTS_Tview

//@version=4

study(title="Ravi teja's consecutive candle", overlay=true)

candleColor = close > open ? color.green : close < open ? color.red : na

// Mark low for the first two consecutive green candles
greenCandleLow = low
greenCandleLow := candleColor == color.green and candleColor[1] == color.green and candleColor[2] != color.green ? low : na

// Mark high for the first two consecutive red candles
redCandleHigh = high
redCandleHigh := candleColor == color.red and candleColor[1] == color.red and candleColor[2] != color.red ? high : na

plotshape(greenCandleLow, style=shape.triangleup, color=color.green, title="Green Candle Low", location=location.belowbar, size=size.tiny)
plotshape(redCandleHigh, style=shape.triangledown, color=color.red, title="Red Candle High", location=location.abovebar, size=size.tiny)

