// Moving Average buffer if (i < Bars - MA_period) MABuffer[i] = GetOBVMovingAverage(MA_period, OBVBuffer, i); //MABuffer[i] = GetOBVMovingAverage(MA_period, MA_method, ExtOBVAppliedPrice, i);
//double GetOBVMovingAverage(int nPeriod, int nMethod, int nAppliedPrice, int nIndex) double GetOBVMovingAverage(int nPeriod, double& array[], int nIndex) { double dMA; //double dOBV_vals[]; double dOBV_vals = 0.0; int j; /*for(j=nIndex+nPeriod; j<=nIndex+1; j--) { dOBV_vals[j-nIndex-1] = iOBV(NULL, 0, nAppliedPrice, j); }*/ for (j = nIndex; j < nIndex + nPeriod; j++) { dOBV_vals += array[j]; } //dMA = iMAOnArray(dOBV_vals, 0, nPeriod, 0, nMethod, 0); dMA = dOBV_vals / nPeriod; return(dMA); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 everyone,
I'm a newbie who recently started learning MQL4. I've been struggling with the problem below for quite a while now without success.
Basically what I'd like to achieve is having the OBV indicator with a moving average in a separate indicator window. I used the OBV.mq4 for a start and gradually started building the code up:
The OBV appears properly on the chart but the MA does not. Instead, I only get a constant 0 line for the moving average. The code doesn't have any warnings or errors.
If someone could help out an enthusiastic newbie, I'd be extremely grateful! :)
P.S: I am aware that I can add moving average to an OBV indicator on MetaTrader. However, the OBV with MA will be part of a future EA that I am planning to program and hence I need the indicator with an OBV and an MA buffers to pass on to the rest of the EA later on.