i is the loop from Bars to 0
There is no bar index equal to Bars, the highest is Bars-1.
Of course I have no more than Bars-1.
There is no "Of course".
You stated
i is the loop from Bars to 0 tf = PERIOD_CURRENT; datetime dt = iTime(NULL,tf,i); int shift = iBarShift("EURUSD",tf,dt,true);
If you are getting values for a different symbol, you should check that there is an equivalent bar index for that symbol.
If the chart has 2000 bars and the symbol that you are trying to get data from only has 1000, you will get the error
- Post real code that compiles. There are no mind readers here and our crystal balls are cracked.
- Bars is the current chart only.
- 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
Use iBars() to see the available number of bars for other instruments.

- docs.mql4.com
Perhaps you should read the manual.
Timeseries
and Indicators Access - MQL4 Reference
Maybe it's not me who need to read the manual.
//+------------------------------------------------------------------+ //| asd.mq4 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- int tf = PERIOD_CURRENT; int bars_current = iBars(NULL,tf); int bars_GBPUSD = iBars("GBPUSD",tf); int bars_USDCAD = iBars("USDCAD",tf); Print("Current ",bars_current); Print("GBPUSD ",bars_GBPUSD); Print("USDCAD ",bars_USDCAD); Print(iTime("USDCAD",tf,bars_USDCAD-1)); Print(iTime("USDCAD",tf,bars_USDCAD)); Print(iTime("USDCAD",tf,bars_USDCAD+1)); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
2020.04.12 21:01:14.047 asd EURUSD,M15: 1970.01.01 00:00:00
2020.04.12 21:01:14.047 asd EURUSD,M15: 2020.03.06 03:30:00
2020.04.12 21:01:14.047 asd EURUSD,M15: USDCAD 2470
2020.04.12 21:01:14.047 asd EURUSD,M15: GBPUSD 2470
2020.04.12 21:01:14.047 asd EURUSD,M15: Current 9537
Download ME the bars above the "iBars".
Print(iTime("USDCAD",tf,bars_USDCAD)); Print(iTime("USDCAD",tf,bars_USDCAD+1));
Why are you trying to get the time for bars that don't exist?
If history can be downloaded using "PgUp" button on current chart, then it's present.
On the other charts it's not downloaded, and indicator not getting correct values.
2020.04.13 13:49:28.814 asdasd EURUSD.rann,M15: src bar 48 EURGBP.rann 2020.04.13 00:45:00 dst bar 48
2020.04.13 13:49:28.814 asdasd EURUSD.rann,M15: src bar 48 EURCHF.rann 1970.01.01 00:00:00 dst bar -1
2020.04.13 13:49:28.814 asdasd EURUSD.rann,M15: OnCalculate: iTime 3 Error 4051
2020.04.13 13:49:28.814 asdasd EURUSD.rann,M15: src bar 48 EURCAD.rann 2020.04.13 00:45:00 dst bar 48
2020.04.13 13:49:28.814 asdasd EURUSD.rann,M15: src bar 48 EURAUD.rann 2020.04.13 00:45:00 dst bar 48
2020.04.13 13:49:28.814 asdasd EURUSD.rann,M15: src bar 48 EURUSD.rann 2020.04.13 00:45:00 dst bar 48
2020.04.13 13:49:28.814 asdasd EURUSD.rann,M15: OnCalculate: EURCHF.rann iTime 2 Error 4051
How to fix this?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How do I download data from an indicator without an error?
Errors on M1 and H1:
EURUSD,M1: Time 2020.04.10 23:58 iBarShift Error: 4051, i = 0, shift = 0 (the bar at 2020.04.10 23:58 is present)
EURUSD,H1: Time 2019.12.04 02:00 iBarShift Error: 4051, i = 2151, shift = 2151 (depends on the first visible bar, or the first downloaded from broker, when I press "PgUp", but I do not want to press "PgUp", especially if I get data from another chart)