iClose for PERIOD_D1 always returns 0 if Shift is >= 400 bars in MT5 but ok in MT4

 

If I use the following code in MT5 it returns ~0 even my data is good and available from 2003, 99% model quality. This means MT5 skips all data that passes 4-500 days. We are migrating to MT5 and lots of our algorithms are based on past data. I feel like MT5 is not as good as MT4. The same code runs just fine in MT4. I tested this with multiple pairs and multiple brokers. I concluded that this is MT5's issue.

iClose(Symbol(), PERIOD_D1, 500)

Can MT5 team help?

 
Please read the help:  Organizing Data Access 
Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
  • www.mql5.com
Organizing Data Access - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

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 (2019)

On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
          Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020.12.15)
          Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
          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 #2 (2018)
          SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019)

 
Both answers do not address my issue. In my case `CopyBuffer` always returns > 0 and when I check the log I see this "2021.11.11 17:39:37.214 Core 1 GBPNZD,Daily: history cache allocated for 300 bars and contains 278 bars from 2019.01.01 00:00 to 2019.12.31 00:00". And I cant get iClose data above 300 bars. Could you explain why it happens in MT5 but not MT4 and how to fix this? I believe this is a bug in MT5.

 
Thang Dang # :
Both answers do not address my issue. In my case `CopyBuffer` always returns > 0 and when I check the log I see this "2021.11.11 17:39:37.214 Core 1 GBPNZD,Daily: history cache allocated for 300 bars and contains 278 bars from 2019.01.01 00:00 to 2019.12.31 00:00". And I cant get iClose data above 300 bars. Could you explain why it happens in MT5 but not MT4 and how to fix this? I believe this is a bug in MT5.

1. Set the maximum story depth:


(don't forget to restart your terminal)

2. Test on the server 'MetaQuotes-Demo'

 
I did all that before but did not help.
 
Thang Dang #:
Both answers do not address my issue. In my case `CopyBuffer` always returns > 0 and when I check the log I see this "2021.11.11 17:39:37.214 Core 1 GBPNZD,Daily: history cache allocated for 300 bars and contains 278 bars from 2019.01.01 00:00 to 2019.12.31 00:00". And I cant get iClose data above 300 bars. Could you explain why it happens in MT5 but not MT4 and how to fix this? I believe this is a bug in MT5.

Seems you only have 278 daily data bars then. So you need to get more history 
 
The issue is my dataset has enough bars back to 2003. This is a bug. Backtesting in MT5 is way harder and slower than MT4 
 
Thang Dang #:
The issue is my dataset has enough bars back to 2003. This is a bug. Backtesting in MT5 is way harder and slower than MT4 

There is no bug. Approximatively 1 year of past data is available in the tester.

Read MT5 documentation and learn to use it.

 
Alain Verleyen #:

There is no bug. Approximatively 1 year of past data is available in the tester.

Read MT5 documentation and learn to use it.

We need more than 1 year(probably 3-5 years) past data ,  but now only 1 year hisitory in the tester,  and we didn't find a way to allocate more history cache.

Reason: