-
Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - 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
1. Because I've never been here before and when I clicked "Traders Forum" the first suitable section is this one (and is simply called "Expert Advisors and Automated Trading", not "MT5 Expert Advisors and Automated Trading"). I didn't look all the way at the bottom where the MT4 section has been buried and there's no way for me to move this post. Apologies for ruining your day.
2. As stated in my post, all history is loaded and I get the same error repeatedly. I know about 4066 and 4073, these errors would only show up if history wasn't loaded.
int OnInit() { int shift=iBarShift(symbol,tf,start_date); Print("Value for "+TimeToStr(iTime(symbol,tf,shift))+"="+get(shift));
- You know about 4066/73. Yet you do nothing to prevent
them. Link #1.2 Unless you've accessed CADJPY/M5 in the last 10 minutes, your
script fails.
- don't try to use any price or server related functions in OnInit (or on load,) as there
may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The code below uses iCustom to get the value of the Stochastic indicator on CADJPY on PERIOD_M5. This is not a problem with the Stochastic indicator or this particular symbol, as the same problem manifests with any symbol/indicator.
The problem is that when this EA is applied to any symbol other than CADJPY, I get different timestamps for the same index, before and after using iCustom. I'm using the latest build of MT4 (1260).
This is not an issue with chart history, as the history is loaded and the same thing happens repeatedly.
Any help would be greatly appreciated!