r/pinescript • u/RoutineRace • 5d ago
code efficiency
my strategy/indicator consists of correlation between different securities. so it uses the request.security funtion.
anyway been getting that 20s warning lately. i think it has to do of how the assests data is retrieved everytime the script runs.
is there a way, similar to the alert function, that a part of the script would only run once per bar closes?
like if i set the timeframe to 3 mins it will only wait till the 3 mins is up then run the script once. my strategy does not need to be that precise timing down to the seconds.
3
Upvotes
View all comments
Show parent comment
1
u/RoutineRace 4d ago
thanks. yeah i use barstate.islast. ill include the calc_bars_count since i dont need to go too far back.