-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
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 - MQL4 programming forum - Page 3 #26.4 (2019)Your image shows the problem with “ADX0: 0”.
Please don't post randomly in any section. Your question is not related to the section you posted.
MT4/mql4 has it's own section on the forum.
This thread has been moved accordingly, so please don't create another duplicate topic.

- www.mql5.com
The code below is only to illustrate or reproduce the situation. I am testing this code using the Strategy Tester , M5, on every tick, visual mode = On
#property strict input ENUM_TIMEFRAMES timeframe1 = PERIOD_CURRENT; input ENUM_TIMEFRAMES timeframe2 = PERIOD_H1; bool mipDebug = true; // Debug mode int minBars; // min number of historical bars to consider the initial calculation int maxBars; // max number of historical bars to consider the initial calculation string g_symbol; int OnInit() { minBars = 15; g_symbol = Symbol(); return(INIT_SUCCEEDED); } void OnTick() { double ADX0 = iADX(getSymbol(), getTimeframe1(), 14, PRICE_CLOSE, MODE_MAIN, 0); Print("validate 1. Timeframe: " + timeframe1 + " , ADX0: " + ADX0); int bars = getBars(timeframe1); Print("validate 2: bars: " + bars + ", minBars: " + minBars); ADX0 = iADX(getSymbol(), getTimeframe2(), 14, PRICE_CLOSE, MODE_MAIN, 0); Print("validate 1. Timeframe: " + timeframe2 + " , ADX0: " + ADX0); bars = getBars(timeframe2); Print("validate 2: bars: " + bars + ", minBars: " + minBars); } int getBars(ENUM_TIMEFRAMES timeframe) { return iBars(g_symbol, timeframe); } int getMinBars() { return minBars; } string getSymbol() { return g_symbol; } ENUM_TIMEFRAMES getTimeframe1() { return timeframe1; } ENUM_TIMEFRAMES getTimeframe2() { return timeframe2; }

- www.mql5.com
void OnTick() { double ADX0 = iADX(getSymbol(), getTimeframe1(), 14, PRICE_CLOSE, MODE_MAIN, 0);
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 - MQL4 programming forum - Page 3 #26.4 (2019)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
MT4: iBars iADX using two timeframes does not work on Strategy Tester. Why ?
I am testing an Expert on M5, but it makes calls to the H1 timeframe.
Thanks !