leave you present candle first
now
REF(HIGH, 1), REF(LOW, 1) first candle
REF(HIGH, 2), REF(LOW, 2) second candle
REF(HIGH, 3), REF(LOW, 3) third candle
REF(HIGH, 4), REF(LOW, 4) fourth candle
let’s code for all three candle with in 4th candle range
REF(HIGH, 4)> REF(HIGH, 3) AND
REF(HIGH, 4)> REF(HIGH, 2) AND
REF(HIGH, 4)> REF(HIGH, 1) AND
REF(LOW, 4)< REF(LOW, 3) AND
REF(LOW, 4)< REF(LOW, 2) AND
REF(LOW, 4)< REF(LOW, 1) AND
now you want to upper breakout
LAST>REF(HIGH, 4)
if you want lower breakout
LAST <REF(LOW, 4)
in if you want both together in alert than use
(LAST>REF(HIGH, 4) OR LAST <REF(LOW, 4))
So full code generating a alert when any range breaks is
REF(HIGH, 4)> REF(HIGH, 3) AND
REF(HIGH, 4)> REF(HIGH, 2) AND
REF(HIGH, 4)> REF(HIGH, 1) AND
REF(LOW, 4)< REF(LOW, 3) AND
REF(LOW, 4)< REF(LOW, 2) AND
REF(LOW, 4)< REF(LOW, 1) AND
(LAST>REF(HIGH, 4) OR LAST <REF(LOW, 4)) run this code
and reply its works and not