• Wed. Jun 19th, 2024

Universal Moving Average Expert – Trading Systems – 7 August 2022


Aug 7, 2022
Universal Moving Average Expert


Trading with the Universal Moving Average Expert 

To keep the EA universal it trades only buy or sell, depending how OrderMode is set. The amount of settings to trade both ways would be confusing.

Besides it would become more confusing if you apply the other settings that are not described in the product description:

Setting OrderMode to 3 or 4 reverses the triggers – details below. (A later version may also permit working with pending orders by the setting OrderMode)  

To trade both, buy and sell in a chart, you must open the same chart 2 times and attach the EA on one set to buy, on the other set to sell. 

As the Uni EA needs very few resources that’s no problem for the system. 

Anyway some symbols just give a good backtesting result buy or sell, so in live trading one should only trade the better mode.

The lines drawn in the chart are the same as explained in the free indicator: Resistance Support Levels >> 

The Strategy

Breakouts over or under a moving average (ma) trigger the trades. The pics below show the basic conditions.

The trigger ma has the smaller period, the code requests that the trigger ma must be above ma2.

Setting OrderMode to 3 opens a buy when the candle crosses the ma down, like the sell shown right hand.

Setting OrderMode to 4 opens a sell when the candle crosses the ma up, like the buy shown left hand.

For now there’s no set file provided for these setting.


The provided set files are optimized for one broker. But different brokers may have different pricing.

In a longer period like H1 charts the effect of the different pricing for the trading result should be small, optimizing may have few impact on the trading result.

But e. g. in scalping in M5 chart the difference may have more effect. There optimizing before live trading is a must.

Once understood optimizing of the Uni MA EA it is a small step to configurate the EA for other charts.

To optimize you don’t have to read the whole article about it, but it may help:  Strategy Optimization – Algorithmic Trading, Trading Robots – MetaTrader 5 Help

The provided set files make optimizing fast and easy, as reasonable test ranges for the optimizing parameters are already set.

It looks like a lot of settings, but many lines are double:

There always the line with the ending  ..Test must be activated in the box left, to find the best result(s) for the parameter.

The optimizing result(s) must then be written in the line below.

Only in the second line it is possible to set several values, if optimizing shows several good results, what is the case often.

Note: There must be always a space between two set values in a line. One digit values must have a 0 (zero) before. 


The first settings to optimize can have just one value, so there’s no second line:

StopLoss should be clear. TakeProfit has 2 settings, the first sets how much profit must be reached, that the EA closes the order at once.

TakeProfit2 depends on the close of the candle (or bar). The value of TakeProfit2 should be a little below TakeProfit.

Then the EA closes a order if the candle close profit exceeds the TakeProfit2 and doesn’t wait for reaching the other TakeProfit (that maybe never reached).


HourStart and LastHourTrade are self explaining, they apply to every trading day, like day 1 = monday, day 2 = tuesday, … 

DayNoTradeTest shows backtesting which day(s) should be avoided to trade the given strategy. Just in few cases we avoid more than one day.

If optimizing shows as best result: 4 in DayNoTradeTest you set 04 in DaysNoTrade and the EA doesn’t open trades on thursdays.

But DayNoTradeTest can be extended to test on which hour of a certain weekday the EA shouldn’t open trades:

So to improve the result reached with the 04 setting you can test on which hour on thursday the EA shouldn’t open trades.

Set 4 at the beginning and the hours to test behind in the testing range of DayNoTradeTest shows these hours.

So for a system working from 8 to 18 o’clock the range for testing a thursday is 408 – 418. Testing same hours on monday is 108 – 118.

The result may become significant better, just avoiding trades in the afternoon or morning of a day.

The change from european to american trading session can be optimized by that for every day. 

Only DayNoTradeTest and DaysNoTrade have a double function – for now.

A good example for that are the default settings of the Uni MA EA.

Optimizing one parameter after the other, from top to bottom, always just one parameter in test, leads to the best result.

To check a new symbol it makes sense to start with a set file of a similar symbol. 

More details later.


Image and article originally from www.mql5.com. Read the original article here.