Update 12/1/2010: this forward test now replaced with a Virtual Order Manager equivalent coexisting with the Support_Resistance EA. See statement here and live screenshot here. All links below are still valid.
This EA is a Moving Average Cross system using the Fractal Adaptive Moving Average. It is almost certainly not a profitable EA - I've just used a simple system like this as an exercise in learning MT5. Give it to me to code in MT4 and I'd have it done in literally 15 minutes, but this has taken me on an off about a week to code.
This EA is a Moving Average Cross system using the Fractal Adaptive Moving Average. It is almost certainly not a profitable EA - I've just used a simple system like this as an exercise in learning MT5. Give it to me to code in MT4 and I'd have it done in literally 15 minutes, but this has taken me on an off about a week to code.
I decided to write an EA that is triggered using an indicator to really understand how things work. The FraMa Cross indicator is here, and includes arrows showing long and short entries. The default MA periods are 6 and 12.
There are various ways to code an always-in-the-market reversing EA such as this in MT5. I simply reverse the position by sending an order for double the lots in the opposite direction, which illustrates one of the largest differences between MT4 and MT5.
Files needed for this EA to compile and run:
FraMa cross EA V1_2.mq5 - the Expert Advisor itself. Store in MQL5/Experts
FraMa cross.mq5 - the indicator. Store in MQL5/Indicators
EnumToStr.mqh - contains lookup tables for a couple of enums. Store in MQL5/Include
SimpleLog.mqh - logging utitlity that I used to debug. Store in MQL5/Include
Here is the statement of a live forward test, which is running on a EURUSD H1 chart with FastMA 6 and SlowMA 12.
[update] and here's a screenshot updated every 10 minutes. You may need to use refresh on your browser to see updates (the picture to the left is an example only and doesn't update)
[update 2] I have uploaded a new version of the EA. It suddenly stopped working properly because I had made an error by not initialising a double in OpenLots(). A recent MT5 update must have stopped automatically initialising doubles.
[update 3] The EA hasn't been working for a while - must have been a new build which broke it for some reason. So I've recompiled after re-writing some of the code, such as OpenLots() (which doesn't need to loop through all positions as I'd orinally written it), and introducing a more versatile function called AdjustPosition(). The code is updated as Frama Cross EA V1_2.mq5