How to detect timeframe in offline non-standard charts

 

Hello Group... I wonder please if someone could help me with what is probably a very trivial thing. I have created several offline charts of non-standard timeframes (ie. 35 min, 40 min, 50 min, 55 min, etc) using the Period_Converter script. I need to apply an indicator to these charts which internally detects what the timeframe of that chart is. It uses of course the "Period()" function which works fine on the built-in timeframe charts, but returns nothing in the offline charts. Does anyone know of a quick and nifty way to programmatically "get" the timeframe of an offline chart?


Thanks!

   Shawn

 
shawnMHello Group... I wonder please if someone could help me with what is probably a very trivial thing. I have created several offline charts of non-standard timeframes (ie. 35 min, 40 min, 50 min, 55 min, etc) using the Period_Converter script. I need to apply an indicator to these charts which internally detects what the timeframe of that chart is. It uses of course the "Period()" function which works fine on the built-in timeframe charts, but returns nothing in the offline charts. Does anyone know of a quick and nifty way to programmatically "get" the timeframe of an offline chart?

Not really possible in a direct method, since it is after all a non-standard time-frame Offline Charts. You will have to "calculate" the time difference between each bar to possible achieve that, but only in the case where you have a fixed time difference. This will not apply to Renko, Range Bars, Point & Figure and the likes because there is no fixed time difference between bars!

In your case, since you mentioned fixed time-frames, you will have to detect this by analysing the the time difference between bars.

 

Thank you Fernando! So as simple as the following then maybe...?

MyTimePeriod = Time[0] - Time[1];


Cheers

    Shawn

 
shawnM: Thank you Fernando! So as simple as the following then maybe...? MyTimePeriod = Time[0] - Time[1];

Yes, but that will only work if all the bars are contiguous and since that it not the case, due to weekends and other such days as well as during periods of inactivity, then you will have to compensate for such failings.

 

Thank you Fernando!


Cheers

   Shawn

Reason: