Number of bars in Daily Timeframe

Created at 25 Apr 2019, 09:09
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!
alexander.n.fedorov's avatar

alexander.n.fedorov

Joined 02.01.2018

Number of bars in Daily Timeframe
25 Apr 2019, 09:09


Hi Panagiotis

 

How do I find a number of bars in a daily Timeframe

 

Regards, 

 

Alexander


@alexander.n.fedorov
Replies

alexander.n.fedorov
25 Apr 2019, 09:28

Should this work:

ms = MarketData.GetSeries(TimeFrame);
int barminutes = (ms.OpenTime.Last(0).TimeOfDay - ms.OpenTime.Last(1).TimeOfDay).Minutes;
int numBarsInDay = (int)barminutes;

 

Regards, 

Sasha


@alexander.n.fedorov

PanagiotisCharalampous
25 Apr 2019, 10:09

Hi Sasha,

I haven't tried it but should work for m1 bars.

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexander.n.fedorov
25 Apr 2019, 14:02

RE:

Panagiotis Charalampous said:

Hi Sasha,

I haven't tried it but should work for m1 bars.

Best Regards,

Panagiotis

It does not work

this one works:

 barMinutes= (int)ms.OpenTime.Last(0).ToUniversalTime().Subtract(ms.OpenTime.Last(1).ToUniversalTime()).TotalMinutes;

 

Regards


@alexander.n.fedorov