I am new to pine script. I want to compare the prices on 2 specific date.
But how would I get the bar_index on a particular date?
Thanks in advance
Get bar index at specific date across all time frames.
//@version=5
anchorTime = input.time(timestamp("20 May 2022 15:00 -0500"), "Date")
anchorBarIndex = (time - anchorTime) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack = bar_index - anchorBarIndex
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With