I have a simple Pine-script that should identify a 5 candle pattern as follows:
When I run it, it does match some correct patterns but I also get matches for:
Can anyone explain what I'm doing wrong?
//@version=5
strategy("Five Candle strategy", overlay=true, pyramiding = 1000)
red_candle = close < open
green_candle = open > close
// find a 5 candle pattern to the left of candle[0] as follows -> red,red,red,green,red
find_candle_pattern = red_candle[5] and red_candle[4] and red_candle[3] and green_candle[2] and red_candle[1]
if find_candle_pattern
strategy.entry("buy", strategy.long, qty=10)
These two are actually the same.
red_candle = close < open
green_candle = open > close
A green candle is defined as
green_candle = close >= open