How to limit MarketData.GetBars?

Created at 07 Jul 2022, 16:40
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!
WO

work_fin

Joined 07.07.2022

How to limit MarketData.GetBars?
07 Jul 2022, 16:40


Hi Guys, 

I'm sure it's possible, perhaps i'm just missing something. 

I want to get the high and low values of the 30 minute timeframe using MarketData.GetBars. so i have the following:

         var lothirty = MarketData.GetBars(TimeFrame.Minute30, Symbol.Name).LowPrices;
         var hithirty = MarketData.GetBars(TimeFrame.Minute30, Symbol.Name).HighPrices;

This works, as expected. Although, it gets ALL the thirty minute data available. How would i only request the last x instances?

If i only wanted to get the last 2 hours worth (4 x 30 mins), i was hoping something like this would work, but it doesn't:

         MarketData.GetBars(TimeFrame.Minute30, Symbol.Name, 4).LowPrices; 

Any help would be appreciated, 

Thanks,


@work_fin
Replies

PanagiotisCharalampous
08 Jul 2022, 11:42

Hi colymaxa,

There is no such option at the moment in the API. You will need to filter the results on your side.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous