-
Why did you post your MT4 question in the
Root /
MT5 Indicators section
instead of the
MQL4 section, (bottom of the Root page?)
instead of the
MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. (The moderators will likely move this thread there soon. - Your buffers and loop is non-series but iMA is as-series. Do it as-series, counting down to zero (current.) Or convert your non-series i to as-series: Bars-1-i
How to do your lookbacks correctly. MAGradBuff[i]=iMA(NULL,0,MAL,0,MODE_SMA,close[i],i);
What do you think the applied_price you are using is?double iMA(iMA - Technical Indicators - MQL4 Reference
string symbol, // symbol
int timeframe, // timeframe
int ma_period, // MA averaging period
int ma_shift, // MA shift
int ma_method, // averaging method
int applied_price, // applied price
int shift // shift
);
sorry i'll post in mql4
Don't double post, the moderators will move it.
mk731:
Hey,
Using MQL4:
I'm trying to get moving average in separate window.
But the values are all wrong, it won't match up one to one, it seems random.
Can you please help me create moving averages in a separate window?
Do it like this :
int OnCalculate (const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[] ) { int counted_bars = prev_calculated; if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit=MathMin(rates_total-counted_bars,rates_total-1); for(int i=limit; i>=0; i--) MAGradBuff[i]=iMA(NULL,0,MAL,0,MODE_SMA,PRICE_CLOSE,i); return(rates_total); }

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
Hey,
Using MQL4:
I'm trying to get moving average in separate window.
But the values are all wrong, it won't match up one to one, it seems random.
Can you please help me create moving averages in a separate window?