How to get n-Bars ago ClosePrices

Created at 22 Aug 2023, 00:30
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!
V.

v.fiodorov83

Joined 24.07.2019

How to get n-Bars ago ClosePrices
22 Aug 2023, 00:30


Hello.

Typically Im using something like Bars.ClosePrices.Last(1) or (2) to get a single ClosePrice of a Bar.

How is it possible to get something like

double closePrices[] = Bars.ClosePrices.Last[1-50] ? To get array/list of last 50 ClosePrices/ For example in OnBar() method 


@v.fiodorov83
Replies

PanagiotisChar
22 Aug 2023, 05:17

Hi there,

Try this

            var last50bars = Bars.ClosePrices.Reverse().Take(50);

Aieden Technologies

Need help? Join us on Telegram


 


@PanagiotisChar

v.fiodorov83
22 Aug 2023, 10:02

RE: How to get n-Bars ago ClosePrices

PanagiotisChar said: 

Hi there,

Try this

            var last50bars = Bars.ClosePrices.Reverse().Take(50);

Aieden Technologies

Need help? Join us on Telegram


 

Thank you! It works as expected


@v.fiodorov83