Hi everybody,
I'm trying to make a new indicator to work as a kind of proof of concept test for an idea that i had, but i can't get it to work to test my idea. I have some experience with the language, but I mainly code EA's, so coding indicators is pretty new to me.
here is the code I am trying to use in the indicator right now:
any help is appreciated and if you can explain why something needs to be a certain way that would be great as well because it would help to know for future reference.
PipSlayer42,
prev_calculated start in 0. So your for statement, the i variable starts in -1, causing "Array out of range" error.
Try to include the line:
for(i=prev_calculated-1;i<rates_total;i++)
{
if (i < 0) continue;
o = open[i];
h = high[i];
l = low[i];
c = close[i];
SusceptibilityBuffer[i] = (h-l)/MathAbs(o-c);
}
Also, if, by chance, open[i] equals to close[i], in the calculation of SusceptibilityBuffer[i] you are dividing by 0, causing error.
Regards,
Jin
PipSlayer42,
prev_calculated start in 0. So your for statement, the i variable starts in -1, causing "Array out of range" error.
Try to include the line:
for(i=prev_calculated-1;i<rates_total;i++)
{
if (i < 0) continue;
o = open[i];
h = high[i];
l = low[i];
c = close[i];
SusceptibilityBuffer[i] = (h-l)/MathAbs(o-c);
}
Also, if, by chance, open[i] equals to close[i], in the calculation of SusceptibilityBuffer[i] you are dividing by 0, causing error.
Regards,
Jin
i got it working. i added in this if statement after equating o, h, l, and c
if(o-c == 0.00000)
o+=0.00001;
to solve the issue of if the open minus close was ever equal to zero and it all just started working. Now i know that i still need some refinement, but thank you for your help
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 everybody,
I'm trying to make a new indicator to work as a kind of proof of concept test for an idea that i had, but i can't get it to work to test my idea. I have some experience with the language, but I mainly code EA's, so coding indicators is pretty new to me.
here is the code I am trying to use in the indicator right now:
any help is appreciated and if you can explain why something needs to be a certain way that would be great as well because it would help to know for future reference.