Bars.ClosePrices.Last(0) changes after 1 second in OnTick method, even though the time frame is one minute.

Created at 04 Oct 2021, 09:10
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
RE

RedSeaBro

Joined 10.04.2021

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.

 

 

 

 


@RedSeaBro
Replies

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

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