Popular results

$ £ ¥
¥ £ $

Adjustable MA Expert Advisor

Adjustable MA Forex expert advisor is a customizable moving average EA that offers flexible configuration 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 a position on an MA crossover and closes it on the next crossover.

Backtesting the Adjustable MA MetaTrader expert advisor shows abysmal results unless extreme curve-fitting with optimization is applied. It isn't recommended to use this EA on a live account. Its main purpose is to offer a quick way to backtest various moving average crossover systems. Make sure you don't over-optimize it and use out-of-sample testing to confirm your own results.


Input parameters

Main

  • Period_1 (default = 20) — the period for the first moving average.
  • Period_2 (default = 22) — the period for the second moving average.
  • MA_Method_Fast (default = MODE_EMA) — the method for the fast moving average's calculation.
  • MA_Method_Slow (default = MODE_EMA) — the method for the slow moving average's calculation.
  • MA_Price_Fast (default = PRICE_CLOSE) — the price type for the fast moving average's calculation.
  • MA_Price_Slow (default = PRICE_CLOSE) — the price type for the slow moving average's calculation.
  • MinDiff (default = 30) — the minimum difference between the MAs for a crossover to count.
  • StopLoss (default = 0) — the stop-loss distance in points. Set to zero to disable.
  • TakeProfit (default = 0) — the take-profit distance in points. Set to zero to disable.
  • TrailingStop (default = 0) — the trailing stop value in points. Set to zero to disable.
  • TrailingStopTriggerProfit (default = 0) — the profit in points for the trailing stop to trigger. Set to zero to disable.
  • TradeDirection (default = Both) — the direction of the trades to take.
  • StartHour (default = 0) — the start time hour (by server time) for the period to trade in.
  • StartMinute (default = 0) — the start time minute (by server time) for the period to trade in.
  • EndHour (default = 23) — the end time hour (by server time) for the period to trade in.
  • EndMinute (default = 59) — the end time minute (by server time) for the period to trade in. The end time minute is inclusive, so if set to 59, the EA will trade until 00 of the next hour.
  • TradeOnMonday (default = true) — if true, the EA will trade on Mondays.
  • TradeOnTuesday (default = true) — if true, the EA will trade on Tuesdays.
  • TradeOnWednesday (default = true) — if true, the EA will trade on Wednesdays.
  • TradeOnThursday (default = true) — if true, the EA will trade on Thursdays.
  • TradeOnFriday (default = true) — if true, the EA will trade on Fridays.
  • TradeOnSaturday (default = true) — if true, the EA will trade on Saturdays.
  • TradeOnSunday (default = true) — if true, the EA will trade on Sundays.
  • CloseTradesOutsideTradingTime (default = true) — if true, the EA will continue closing its trades outside of the trading period set using the input parameters above.
  • DoTrailingOutsideTradingTime (default = true) — if true, the EA will continue trailing the stop-loss of its trades outside of the trading period set using the input parameters above.

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.

Miscellaneous

  • Slippage (default = 30) — the acceptable price slippage in points.
  • OrderCommentary (default = "Adjustable MA") — the commentary for positions opened by this EA.
  • DisplayStatusComment (default = true) — if true, a status panel will be displayed in the top-left corner of the chart with details about the EA's operation.
  • Magic (default = 19472394) — a Magic number to use with trades.

MiniFAQ

What are the best settings to use with this EA?

There are no known best settings. We didn't find any consistently profitable combinations of parameters. You are welcome to backtest it to try and find some worthwhile strategies.

 

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.


Download (ver. 1.08, 2026-04-17)

Adjustable MA expert advisor for MetaTrader 4Download Zipped Adjustable MA expert advisor for MetaTrader 4Download Adjustable MA advisor for MetaTrader 5Download Zipped Adjustable MA expert advisor for MetaTrader 5Download

Warning!

This expert advisor isn't profitable on its default settings. Do not run this EA on a live account! Use it for educational purpose only.

Discussion

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.

Warning!

Before asking questions about installing this expert advisor, please read our MetaTrader Expert Advisors Tutorial to learn how to install an EA.


Changelog

1.08 - 2026-04-17

  • Added a status panel via the chart commentary.
  • Added input parameters for the price types to use in MA calculation.
  • Added separate input parameters for each MA's calculation mode.
  • Added an input parameter for trailing stop trigger profit.
  • Added input parameters to restrict trading on certain days of the week.
  • Added support for cross-midnight time periods.
  • Added validation for more of the input parameters on initialization.
  • Added None as a trading direction to only close trades or trail stops without opening new positions.
  • Changed the start/end time input parameters from strings to integers to allow backtesting optimization based on time periods.
  • Changed the EA to work with points only without assuming what a pip is for a given trading instrument.
  • Changed Magic number from an implicitly calculated value to a modifiable input parameter.
  • Fixed a bug with position closing that could (very rarely) occur with the MT4 version of the EA.
  • Fixed multiple issues in the money management function of the EA.
  • Fixed a bug in the MT4 version that would cause it to read MA values from an incomplete candle.

1.07 - 2025-02-10

  • Added an option to restrict trading to a certain period of the day.
  • Added an option to restrict trading to a single direction.
  • Optimized trailing stop to make it work more reliably.
  • Changed how trades are opened and closed to allow for several attempts in case of a failure.

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.