Loading indicators referencing other timeframes

 

Hi,

I want to ask you, if it is possible, inside an EA to load an indicator from another timeframe, different of the current timeframe.

Let’s say I load my EA in EURUSD PERIOD_M15. And I want to see the MACD indicator (12, 26, 9); but not about PERIOD_M15, BUT in reference to PERIOD_D1.

thanks!

 
Yes.
 
Yes, but On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing prices. (Or indicator output.)
          Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 № 26

The function linked to, opens a hidden chart for the symbol/TF in question (if not already open,) thus updating history, and temporarily placing the symbol on Market Watch (if not already there,) so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't also return zero the first call.

 

Ok. Let’s say, I load my EA in EURUSD M15, and I want the value of the MACD in H1, I execute this:

 


if (downloadHistory(Symbol(), PERIOD_H1)) {
   double res = iMACD(Symbol(), PERIOD_H1, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
}



 

BUT, what I have to do to get the MACD visualized in the chart (using H1, not M15)?

 

EAs have no eyes, they don't visualize anything. You have the H1 value. What you do with it is up to you.

If you want to visualize it, put a MTF version of the MACD on your chart, Print it, or put it in a Comment, etc.

 
William Roeder:

EAs have no eyes, they don't visualize anything. You have the H1 value. What you do with it is up to you.

If you want to visualize it, put a MTF version of the MACD on your chart, Print it, or put it in a Comment, etc.

I understand.

Sorry, what is 'MTF'? (=********)

 
Multi-Time-Frame
Reason: