Code Library / Moving Average

MQL4 Hull Moving Average

Hull Moving Average (HMA) with reduced lag.

Language: MQL4 · Category: Moving Average · Tags: Hull MA, HMA, MQL4, indicator, low lag

Source code

double HMA(string sym,int tf,int period,int shift) {
   int half=(int)MathFloor(period/2.0);
   double w1=iMA(sym,tf,half,0,MODE_LWMA,PRICE_CLOSE,shift);
   double w2=iMA(sym,tf,period,0,MODE_LWMA,PRICE_CLOSE,shift);
   return 2*w1-w2;
}

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own MQL4 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.

Related snippets