Using multiple time periods...

 

Is there a way to get your EA to reference candles constructed from different time periods?

For instance, if I wanted it to consider the high of the H1 candle and the close of the previous H4 candle?


At the moment I only know how to get it to use the one time frame and count back, but that becomes a moving target.

I would prefer it to be able to reference formed candles in other time frames...

 
seems that the forum has automatically answered my question for me..! :D
 

Actually, I'm still having issues.


iClose(Symbol(),Period_MN1,1


Where am I going wrong..?

 
rogue1:

Actually, I'm still having issues.

iClose(Symbol(),Period_MN1,1

Where am I going wrong..?

iClose(Symbol(),PERIOD_MN1,1)

(Edited)
 
Keith Watford:

I included the brackets in the EA, but not in the example...

 
I just found that it says "Period_MN1'' - undeclared identifier"...
 
rogue1: I just found that it says "Period_MN1'' - undeclared identifier"...

Of course, it does. Perhaps you should read the manual a little closer.
          Constants, Enumerations and Structures / Chart Constants / Chart Timeframes - Reference on algorithmic/automated trading language for MetaTrader 5

 
William Roeder:

Of course, it does. Perhaps you should read the manual a little closer.
          Constants, Enumerations and Structures / Chart Constants / Chart Timeframes - Reference on algorithmic/automated trading language for MetaTrader 5

Got it, thanks.


In the link above, the solution provided is in lower case...

 
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

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 on the first call.

On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
          Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum
          Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
          Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum
          SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum 2019.09.03

Reason: