简体   繁体   中英

How to retrieve an offset from a past event? Pine Script V5

SomethingHappens[0] happens in the present so it happens at same candle as close[0] .

But SomethingHappens[1] (if I'm not wrong that we can address events in a series this way) happened in the time of close[x] where x is anything, eg 2 , 329 …, etc. – it changes all the time as the chart flows. We want to know what's that x in this close[x] to address the candle of that SomethingHappens[1] .

Is there a way to retrieve that offset?

It sounds like you can use ta.barssince() for this.

x = ta.barssince(SomethingHappens)

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