Do not double post.
I have deleted your other topic.
Hi,
I am learning coding MQL4 and I have been having some problem creating a class with Arrays so that the output can be used in an indicator code. I have done some work but I don't seem to get it to work and am getting array out of range error. Please I am learning I need some guidance on how to sort this out. Please see the .MQH file and the MQL file.
need some help in solving this problem. I have used the Comment() function to see if i could find out why this is happening, but the outputs seem to be OK.
The problem is on these lines. If Difference output is 30333 and i manually enters that (DSS = delta / 30333) this works fine then the next line gives array out of range error.
DSS = delta / Difference; // Zero divide errow - on this line.
pMainBuffer[pShift] = psmooth_coefficient * (DSS - pMainBuffer[pShift+1]) + pMainBuffer[pShift+1]; // Array out of range in this two lines.
pDssBuffer[pShift]= pMainBuffer[pShift];
I took a quick look at it. I don't see that you initialized the pPeriod variable, so _period is also without initialization.
If I am right, the HighRange and LowRange are equals, for this Difference is 0, this is why you get the zero divide.
I took a quick look at it. I don't see that you initialized the pPeriod variable, so _period is also without initialization.
If I am right, the HighRange and LowRange are equals, for this Difference is 0, this is why you get the zero divide.
Thanks for looking in to this , if you comment out the two lines and look at the output on the chart screen
Highrange and LowRange are not equal based on the output.
Highrange = 90.1207369.....
LowRange = 59.790029.....
Difference is not 0 it is 3033.07072839622
This is why i don't seem to see where the problem
Thanks for looking in to this , if you comment out the two lines and look at the output on the chart screen
Highrange and LowRange are not equal based on the output.
Highrange = 90.1207369.....
LowRange = 59.790029.....
Difference is not 0 it is 3033.07072839622
This is why i don't seem to see where the problem
Difference is surely zero, if you got zero divide error.
If Difference is 3033.07072839622, you did not get zero divide.
But the output for Difference is not zero. i will continue try to find out why. thanks
But the output for Difference is not zero. i will continue try to find out why. thanks
have you tried running the code with the files i sent?
have you tried running the code with the files i sent?
No. But it is 100% sure, that your Diff is zero, otherwise there cannot be zero divide error.
I recommend you to check out my first answer again to see the problem.
- 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,
I am learning coding MQL4 and I have been having some problem creating a class with Arrays so that the output can be used in an indicator code. I have done some work but I don't seem to get it to work and am getting array out of range error. Please I am learning I need some guidance on how to sort this out. Please see the .MQH file and the MQL file.
need some help in solving this problem. I have used the Comment() function to see if i could find out why this is happening, but the outputs seem to be OK.
The problem is on these lines. If Difference output is 30333 and i manually enters that (DSS = delta / 30333) this works fine then the next line gives array out of range error.
DSS = delta / Difference; // Zero divide errow - on this line.
pMainBuffer[pShift] = psmooth_coefficient * (DSS - pMainBuffer[pShift+1]) + pMainBuffer[pShift+1]; // Array out of range in this two lines.
pDssBuffer[pShift]= pMainBuffer[pShift];