Pine script -How to write a script that detects eight similar consecutive candles

172 views Asked by At

Want to write a pine script that gives an alert after 8 consecutive similar candles and gives an alert after the 8th or on the 8th candle.

1

There are 1 answers

0
rumpypumpydumpy On BEST ANSWER
greenCandle = close > open ? 1 : 0

cond = sum(greenCandle, 8) == 8

alertcondition(cond, title = "Alert", message = "8th green!")