rjuku
rjuku

Reputation: 11

candle close higher than past 20 candles (minus the current one)

messing around with a breakout strategy, cant figure out how to write close > highest high in last 20 candles without the current one. I think that this:

    hh = ta.highest(high, 20)
    if (close > hh)
    strategy.entry('long', strategy.long)

doesnt work as the candle that closes past the range is the one becoming the highest one by definition, any tips?

cheers

Upvotes: 1

Views: 287

Answers (1)

Dave
Dave

Reputation: 865

hh = ta.highest(high, 20)[1]
if (close > hh)
   strategy.entry('long', strategy.long)

Upvotes: 0

Related Questions