• Get access

Multiple candle sizes in EA.

To add comments, please log in or register
Mikołaj Gogola
51
Mikołaj Gogola  

Hi,

Is it possible for EA to access arrays of candles with different size than current Chart size?

I want my EA to perform some calculations on 1-minute candles but other on 1-hour candles. Can it be done?

Lorentzos Roussos
19705
Lorentzos Roussos  
Mikołaj Gogola:

Hi,

Is it possible for EA to access arrays of candles with different size than current Chart size?

I want my EA to perform some calculations on 1-minute candles but other on 1-hour candles. Can it be done?

You mean other timeframes ? yes it can be done ,but you must be ever-vigilant to request the correct candles and never assume data exists already (downloaded) ,as William will point out . 

Mikołaj Gogola
51
Mikołaj Gogola  
Yes I think I am talking about timeframes.
For example I want to calculate difference between Close[2] and Close [5], but also Close[4] and Close[1500].
I did call ArraySize() on Close and it returned around 67000 so it is weird that I am receiving "array out of range" when accessing Close[1500].
Anyway if I could switch somehow to 30min candles and access Close[50] it would be same as 1500 on 1 minute Chart and should fix my problem.

The reason can be Tick Data Suite software I am testing recently. It allows to test historical data later than regular Strategy Tester and it may be the reason of errors. I don't know really.
William Roeder
20368
William Roeder  
  1. 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

  2. Don't mix apples and oranges.
Mikołaj Gogola
51
Mikołaj Gogola  
Thank you William.
I actually got an email from TDS support team where they explained that I have to define preliminary amount of bars in "Advanced settings" before running backtest. (default number was 100)
To add comments, please log in or register