OCHL ratio indicator Moving Average error
Your code double openClosePips;
if(open[i] > close[i]) { openClosePips = open[i] - close[i]; } else { openClosePips = close[i] - open[i]; }
Simplified double openClosePips = MathAbs(open[i] - close[i]);
-
double OCHLRatioMa = iMA(Symbol(), Period(), MAPeriod, 0, MAMethod, OCHLRatio, i);
The second from the last is a price enumeration — you pass a value. Bogus. Research iMAOnArray.
Thank you William.
After hassling with iMAOnArray I got it to work.
I have attached the indicator, if anyone need such a ratio and moving average.
This is how it looks like with 10 day MA.
Files:
OCHL_ratio.mq4
6 kb

Hi,
I'm was looking for an indicator, but can't seem to find one. So I created my own, but can't figure out how to get the moving average value correct.
If you take a look at the code then all values are correct until the return of iMA(). You can see the result for each day on the image. For somereason it is 0.98 on average. You can also see the green line on the indicator below.
Does anyone know why it is not returning the correct moving average? :)
Thank You,
Hendrik