What bar does Bars.ClosePrices.Last(0) return in OnBarClosed()?

Created at 27 Feb 2024, 08:42
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!
IG

iggys77

Joined 20.02.2024

What bar does Bars.ClosePrices.Last(0) return in OnBarClosed()?
27 Feb 2024, 08:42


In the docs it says that

“When accessed in this event handler, the Bars collection does not contain the current live bar, whereas other collections (e.g., Positions, Symbols, etc.) contain actual data.”

 

Does this mean that

Bars.ClosePrices.Last(0)

inside the OnBarClosed() event handler returns the previous bar's close price (whereas Last(0) would typically return the current one)?

 

 

 

 


@iggys77
Replies

PanagiotisCharalampous
27 Feb 2024, 09:44

Hi there,

In OnBarClosed() Bars.ClosePrices.Last(0) represents the bar that has closed.

Best regards,

Panagiotis


@PanagiotisCharalampous

iggys77
27 Feb 2024, 12:57

Thanks


@iggys77