Calculating indicator in other timeframes than the one visualized?

 

A few months ago I saw a system/indicator that calculated it's values based on other timeframes, than the one present for visualization. Ex. I'm looking on H4-charts, but I want to know the value for H1 avg true range.

(yes, I can do this manually, but its for an ea)

I don't remember how they solved this, anyone got any ideas? It seems very complex to me to save all pricedata within the H4 bar of 1m, and then convert to H1 within the indicator. I think (hope) there's an easier way..

/Johan

 
Flirrrt:
A few months ago I saw a system/indicator that calculated it's values based on other timeframes, than the one present for visualization. Ex. I'm looking on H4-charts, but I want to know the value for H1 avg true range.

(yes, I can do this manually, but its for an ea)

I don't remember how they solved this, anyone got any ideas? It seems very complex to me to save all pricedata within the H4 bar of 1m, and then convert to H1 within the indicator. I think (hope) there's an easier way..

/Johan

Well, it is quite simple.

Take a look : double iATR( string symbol, int timeframe, int period, int shift)

I bolded 2 important parameters to do it. First is the timeframe which you want to read. Second is the shift of value ON REQUIRED timeframe according to current timeframe.

eg. if you wish to read m1 current bar atr on h4 timeframe you should write it like that :

double iATR(Symbol(), 1, 14, 0);

if you wish to read closed m1 bar atr:

double iATR(Symbol(), 1, 14, 1);

Hovever if you want to do somethig like read h4 value on m1 timeframe then you need to use iBarShift function as last param.

 
Flirrrt:
A few months ago I saw a system/indicator that calculated it's values based on other timeframes, than the one present for visualization. Ex. I'm looking on H4-charts, but I want to know the value for H1 avg true range.

(yes, I can do this manually, but its for an ea)

I don't remember how they solved this, anyone got any ideas? It seems very complex to me to save all pricedata within the H4 bar of 1m, and then convert to H1 within the indicator. I think (hope) there's an easier way..

/Johan

If you want to do this in real time in an EA, just do what Kalenzo suggests, and pass the appropriate timeframe parameter to each function. If your looking to do this with an indicator, then take a look at the various MTF indicators available by searching this site, and reference them using iCustom.

regards

zu

Reason: