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 I'm getting an "array out of range" exception for a very simple indicator within the Meta Editor debugger.
The initial values after the indicator starts are the following:
Bars: 218
countedBars=0
In effect the code try to address the rsi[218] element but the arrays in MT4 are zero-based. The code should address rsi[217] element.
I think that the error is correctly raised but when I launch the indicator directly inside MT4 (without the debugger) it works fine... (#@#?#).
The same problem arises in other sections of the code and every time I'm getting an "array out of range" exception. Again when the indicator is used directly from within MT4 (without the debugger) it works fine. I spent a lot of time with no results, but I am very very new with MT4-MT5, so probably there is some thing I have to understand yet.. can you help me?
//+-------------------------------
// code sample used with the debugger
//+-----------------------------
double rsi[];
void OnStart()
{
int countedBars = IndicatorCounted();
if(countedBars < 0) countedBars=0;
CalculateIndicator(countedBars);
}
void CalculateIndicator(int countedBar)
{
for (int i = Bars - countedBars; i >= 0; i--)
{
rsi[i] = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i); // Bars==218 - countedBars==0 i==218-- Here is the Out of range exception
}
}