简体   繁体   中英

Remaining seconds until bar close - pine script

I'm trying to calculate the remaining seconds in real time until the bar closes.

I did this:

" timeLeft = barstate.isrealtime? (time_close - timenow) / 1000: na

secLeft = floor(timeLeft)

plot(series=secLeft, title="Seconds left") "

But the problem is that timenow is not updated often enough (I have calc_on_every_tick=true) and because of that the seconds are not in real time.

Picture

Can anyone help?

Your technique is sound, but see the usrman on execution in the realtime bar .

Execution of Pine scripts in the realtime bar is event-driven. When no user action (like a change in the script's Inputs ) causes a re-execution, it requires a price or volume update to be detected on the feed, which happens at random intervals.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM