Hull Moving Average's Trend System

 

The system was posted by bradman when he needed this system coded.

The system is simple. Long when HMA trend is up, and short when HMA trend is down.

Attached is the EA, automated script for metatrader 4, and indicator of this system. You must install both of them.

This expert advisor features:

  • You can trade multiple charts or currencies at the same time
  • Stop loss, take profit, breakeven
  • Trailing stop
  • Configurable settings
  • Many hidden features. (Advance users, put "extern" to reveal them)

How to use:

  • To enable stop loss, set SL_Mode = 1, then you configure SL to suit your style.
  • To enable trailing stop, set TS_Mode = 1. Trailing stop will hit when profit is x pips as specified in TS_Trigger.
  • Configure the indicator by settting HMA_Period and HMA_Mode.

Cheers!

Files:
HMA.mq4  4 kb
 

Make sure you install the HMA.mq4 in ..\Metatrader 4\experts\indicators folder and HMA Trend EA.mq4 in ..\Metatrader 4\experts

 

Finally, a coder (Scorpion) who puts some depth into his code. I too am a programmer, but so far, have not seen much code published out there that I would trust real money to, let alone waste my time with. Nice work Scorpion.

Mark

 

I did some backtesting on the HMA Trend EA for the last 2 months with profitable results ($11,500) using 1hr charts with 99 periods and mode 0. It shows 22 wins and 6 losses and have included the settings on the tester. Spreads were $840 using 28 trades X 3 pips so total profit was $10,660.

It is one of only a few profitable EAs that I've seen.

Files:
 

I hate moving averages in backtest, try it on a demo account and see how it goes.

 

This EA may have some problems because it closes and opens a new order at the same time. A delay may be needed to correct this.

 

Why? I think it's normal that a trade closes and then opens at the same time. Because this system has the same entry and exit, this will occur all of the time if you don't set SL, TP, breakeven or trailing stop.

Maybe you expect that it opens at the end of candle?

 
You may get profitable experts in backtests if orders are filled and exited in the same bar. This is usually an error due to the limitations of backtesting on data with longer timeframes than the trading strategy.The only way to have reliable backtests off bar data is to either enter on the open or exit on the close

Placing 2 orders at the same time may present problems.

https://www.mql5.com/en/code/9500

https://www.mql5.com/en/articles/1355

 

Are you sure that there were 2 orders at the same time? It could be bug in the expert, but I'm doubt there's any, since the code base has been used for months without problem. There's a possibility that you attached the EA to multiple charts of same currency pair.

If you're talking about the delay, I've implemented Smart Delay in the EA. Before an order is executed, the EA checks if MT4 is available to execute or not. Order is executed according to MT4 state. If it's busy, wait. If it's not busy, don't wait. Smart Delay is more decent than that shown at mql4.com which uses very classic, fixed-interval, always delay.

 

Thanks a lot scorpion.

It is easy to check the charts looking back as the colours stay the same.

when it is changing the colour flickers a lot, so trading Hull forwards is very difficult, and a 24 hour job.

and you lose the pip spread for each false open and close.

hope this EA does good long term.

i've saved the file, but can't test it for a while as i am busy.

keep posting fellers!

 

Backtesting gives exit entry at the same time. I assume live trading with Smart Delay prevents this.

There are many hidden features that look interesting but are not explained :

TS_MODE

TS_MODE_HALF_VOLATILITY

TS_MODE_BREAKOUT

TS_MODE_BREAKEVEN

Lots_PCT

Breakeven_Pips

This EA looks like it has great potentail. Thanks for the effort.

Reason: