Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Hull Moving Average - MetaTrader 4 Script - MQL5 #13491 - MT4/MT5 Resource

author EAcpu | 3 reads | 0 comments |

Hull Moving Average - indicator for MetaTrader 4

Hull Moving Average - indicator for MetaTrader 4

Hull Moving Average - indicator for MetaTrader 4

Hull Moving Average - indicator for MetaTrader 4

Developed by Alan Hull, the Hull Moving Average (HMA) is an extremely fast and smooth moving average that almost completely eliminates lag while managing to improve smoothness. To do this, Allen wrote an equation for calculating a moving average, as follows:

LWMA[square root(period), (2*LWMA(period/2, price)-LWMA(period, price)]

Through this clever equation, Allen gets a very fast moving average that is more responsive to price action.

For a full explanation of how this works you can visit: http://alanhull.com/hull-moving-average

You can use it in two main ways:

I've written the code so that you can change the type of moving average used in the calculation (but this is no longer a true Hull Moving Average) and the price applied. I like to use typical prices to consider what is happening on each candle.

Hull Moving Average - indicator for MetaTrader 4

Hull Moving Average - indicator for MetaTrader 4

Hull Moving Average - indicator for MetaTrader 4

Hull Moving Average - indicator for MetaTrader 4

In the "Custom indicator initialization function" section of the code you will see the following line:

 Set index style ( 0 , DRAW_NONE );

If you write DRAW_LINE, you will see another line on the graph, representing this part of the equation:

2*LWMA(period/2, price)-LWMA(period, price)

This is the calculation before the HMA algorithm, but without the smoothing effect of applying a moving average to the moving average. You can use these lines just like HMAs from two different periods.


Attachment download

📎 hma.mq4 (4.7 KB)

Source: MQL5 #13491

Verification code Refresh