$ £ ¥
¥ £ $

Adjustable MA Expert Advisor

Adjustable MA Forex expert advisor is a customizable moving average EA that offers flexible tuning of the traditional 2-MA cross strategy. You can set different MA periods, MA types, minimum difference, stop-loss, take-profit, trailing stop and slippage. This expert advisor always opens position on cross and closes it on the next cross.

The back-test of the Adjustable MA MetaTrader expert advisor has shown ~12.2% profit with ~12.6% maximum drawdown during a 6-year period. The used position's volume was set to 0.1 standard lots. The EA made 647 trades, of which 56.41% were profitable. The default settings were used in this back-test on EUR/USD M5 chart. As you can see, the results are not very good. It is not recommended to use this EA on live account.

Input parameters


  • Period_1 (default = 20) — the period for the first moving average.
  • Period_2 (default = 22) — the period for the second moving average.
  • MA_Method (default = MODE_EMA) — the method of moving average calculation.
  • MinDiff (default = 3) — the minimum difference between the MAs for a crossover to count.
  • StopLoss (default = 0) — the stop-loss distance in pips. Set to zero to disable.
  • TakeProfit (default = 0) — the take-profit distance in pips. Set to zero to disable.
  • TrailingStop (default = 0) — the trailing stop value in pips. Set to zero to disable.

Money management

  • Lots (default = 0.1) — the volume for trades. Used if UseMM is set to false.
  • UseMM (default = false) — if true, a money management model based on the available free margin is used to calculate the position size.
  • LotsPer10000 (default = 1) — the number of lots to trade per each $10,000 of the account's free margin.


  • Slippage (default = 3) — the acceptable price slippage in pips.
  • OrderCommentary (default = "Adjustable MA") — the commentary for positions opened by this EA.


What are the stop-loss and take-profit values used by this EA?

By default, it uses fixed stop-loss at 100 pips and take-profit at 70 pips. The trailing stop is turned off by default.

How often does it trade?

On 5-minute EUR/USD chart (the back-test settings) this EA will trade once every day on average.

Any settings other than default can be used?

The limited forward test (which should be more reliable than a back-test) on AUD/USD M5 chart showed some profitable set-up for this expert advisor. These parameters should be changed from default:

  1. StopLoss — 30
  2. TakeProfit — 50
  3. TrailingStop — 20
  4. Period_1 — 50
  5. Period_2 — 10

This EA is ECN-compatible. If you are trading with an ECN broker (with market execution for orders), you cannot set SL/TP on position opening. You have to open a position first without SL/TP and only then modify it, adding stop-loss and/or take-profit level. This EA will do it automatically.


Warning! Before you ask basic questions regarding installation of the expert advisors, please, read this MT4 Expert Advisors Tutorial to get the elementary knowledge on handling them.

Do you have your own trading results or any other remarks regarding this expert advisor?

Discuss Adjustable MA with other traders and MQL programmers on the experts forums.


1.06 - 2022-04-21

  • Minor code improvements.

1.05 - 2018-07-25

  • Added automatic detection of execution mode used in the trading account.
  • Fixed EA's operation in MT5 hedging mode.
  • Improved the source code by making simpler and more serviceable.

1.04 - 2012-05-28

  • Added ECN-compatibility.

1.03 - 2011-10-18

  • Fixed a bug with trailing stop.

1.02 - 2011-05-06

  • Added optional money management.

1.01 - 2010-12-15

  • Fixed a bug that appeared due the change in how MT5 processes orders.

1.00 - 2009-12-09

  • Adjustable MA expert advisor released.