Alexandros Chontos: I keep getting "array out of range
You have two buffers:
SetIndexBuffer(0, SMIBuffer); SetIndexBuffer(1, SMI_SignalBuffer);
Yet you try to post to unsized arrays
LLBuffer[i]=iLow(NULL,0,iLowest(NULL,0,MODE_LOW,K_length,i)); HHBuffer[i]=iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,K_length,i)); HH_LLBuffer[i]=iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,K_length,i))-iLow(NULL,0,iLowest(NULL,0,MODE_LOW,K_length,i)); RelDiffBuffer[i]=iClose(NULL,0,i)-(iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,K_length,i))+iLow(NULL,0,iLowest(NULL,0,MODE_LOW,K_length,i)))/2; ⋮ MA_HH_LLBuffer[i]=iMAOnArray(HH_LLBuffer,0,D_length,0,MODE_EMA,i); MA_RelDiffBuffer[i]=iMAOnArray(RelDiffBuffer,0,D_length,0,MODE_EMA,i); ⋮ AvgDiffBuffer[i]=iMAOnArray(MA_HH_LLBuffer,0,D_length,0,MODE_EMA,i); AvgRelBuffer[i]=iMAOnArray(MA_RelDiffBuffer,0,D_length,0,MODE_EMA,i);
What do you think the problem is?
William Roeder:
Hmmm... point taken. It so happens that up to now I’ve used arrays only as preset buffers in mql4 and thought they automatically set size as buffers do. You have two buffers:
Yet you try to post to unsized arrays
What do you think the problem is?
I also set the ArraySetAsSeries to true and all works as a clock! Case closed!
Thanks friend! 😁
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
Hello community,
Before writing here I made sure I looked around to find a solution to my problem. Up to now I always did and I've solved "Array out of range" issues in the past, but know I can't seem to find the problem.
I coded a very simple version of the Stochastic Momentum Index for MT4, all logic seems ok and it compiles right, but I keep getting "array out of range in 'SMI.mq4' (89,15)" when I run it.
I marked the corresponding line, but the problem is not only in that one, when I omit it it gives the same error to the next line and then the next and so on and so forth.
Any help is appreciated. Attaching code bellow.
Thanks in advanced