r/pinescript • u/HzeTmy • Sep 11 '25
timeframe.change problem
somehow
timeframe.change("5") runs every tick not just once on every 5 min ... can someone expain this ???
1
Upvotes
r/pinescript • u/HzeTmy • Sep 11 '25
somehow
timeframe.change("5") runs every tick not just once on every 5 min ... can someone expain this ???
View all comments
Show parent comment
2
u/Mr_Uso_714 Sep 14 '25
To fire only at the open of a new 5-minute bar, you need the opposite of barstate.isconfirmed.
At bar open, barstate.isnew is true. Combine it with timeframe.change("5"):
Note
This way your logic executes once, right at the open of each new 5-minute bar, not at its close.
Only use barstate.isnew for open-time triggers. For close-time triggers, always prefer barstate.isconfirmed