I´m kinda new to scripting, So the thing is I set this tiny script to color the background when the candle crosses over the price of the laste candle, which works fine when that happens.
But if the price retracts and closes lower of the previous candle the coloring dissapears. How can I leave the background painted, even if the price retracts?
//@version=5
strategy(title="Crossup", calc_on_every_tick=true, overlay=true)
closeHigher = (close > high[1])
bgcolor(color=closeHigher ? color.rgb(6, 46, 8, 56) : na)
In that case, you don't want to use close
. Instead, you should use high
. Once current bar's high
is higher than the previous bar's high
, there is no way for that condition to become false
. high
will not go any lower, it can only go even higher :)
//@version=5
strategy(title="Crossup", calc_on_every_tick=true, overlay=true)
closeHigher = (high> high[1])
bgcolor(color=closeHigher ? color.rgb(6, 46, 8, 56) : na)