//---- last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars;
An "Array out of Range" error occurs because when "counted_bars" is 0, "limit" is equal to "Bars"
Nagisa Unada:
An "Array out of Range" error occurs because when "counted_bars" is 0, "limit" is equal to "Bars"
Tried but still note fixed.
I'm rewriting the whole code based on some other approach now so might solve it eventually.
Thank you very much.
yum1573:
Tried but still note fixed.
I've not fixed your program, I'm just pointing out where it's causing the trouble. Don't you understand that?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi everyone
I modified MT4's official DMI+ADX indicator(https://www.mql5.com/en/code/7955) to make it same as other other platforms.
The change is, MT4 calculates the EMA of (±DM/TrueRange) for ±DI while my version is to calculate EMA of ±DM and TrueRange separately then divide them. The ADX part is untouched.
- MT4's original version: ±DI = 100 * EMA(±DM/TrueRange)
- My version: ±DI = 100 * EMA(±DM) / EMA(TrueRange)
Well the ±DI part went well and displayed correctly in MT4.
However, the problem is the ADX line somehow disappeared mysteriously. Related code is even not changed! I tried a lot but still can't figure out what's happening. Can anyone help to find out the reason?
Thank you very much.