skb
Pine Script Rookie
Pine Script Rookie
Posts: 3
Joined: April 23rd, 2021

Finding a pattern of one or more candles

Hello,

I'm looking to develop an indicator that finds the following pattern:

First candle is red and a "leg" candle.
The next 1 to 4 candles are a "base" candle (color doesn't matter)
The next 1 to 4 candles are a "leg" candle (must be "green")
The next candle is a "base" candle (color doesn't matter)

I've written basic code to find the pattern Red Leg, Base, Green Leg, Base, but I don't know how to tweak it so that it recognizes the "1 to4 candles condition.

Can you point me to example code on how to do this?

Thanks in advance,
Steve

Return to “Pine Script Q&A”