Bars.ClosePrices.Last(0) changes after 1 second in OnTick method, even though the time frame is one minute.
Bars.ClosePrices.Last(0) changes after 1 second in OnTick method, even though the time frame is one minute.
04 Oct 2021, 09:10
Hi all:
I am doing backtest with tick data from server (accurate) on GBPNZD in 5-minute timeframe.
I printed Bars.ClosePrices.Last(0) in OnTick method and found it was constantly changing within a minute, sometimes even after 1 second. Why is that?
I thought Bars.ClosePrices.Last(0) should be the same in one timeframe.
Replies
RedSeaBro
14 Nov 2021, 14:42
RE:
amusleh said:
Hi,
The Bars.ClosePrices.Last(0) gives you the latest open bar close price, and it will change because the bar is still open and not closed yet.
If you want to get the latest closed bar close price then you should use Bars.ClosePrices.Last(1).
Thanks a lot. This is really helpful.
@RedSeaBro
amusleh
04 Oct 2021, 10:19
Hi,
The Bars.ClosePrices.Last(0) gives you the latest open bar close price, and it will change because the bar is still open and not closed yet.
If you want to get the latest closed bar close price then you should use Bars.ClosePrices.Last(1).
@amusleh