Skip to content
Forex Indicator System Thailand
Back to marketplace
TrendEAHigh

Adjustable MA (MA crossover EA)

EA that trades the crossover of two moving averages, with adjustable method, period and price

Adjustable MA (MA crossover EA) on an MT5 chart
Example on an MT5 chart

Download this EA for free

Download right away. Nothing to fill in.

Version
1.08
Published
11/21/2026
File size
53 KB

Open source, Apache License 2.0, by EarnForex.com. See licences

Version history

  1. 1.08Current11/21/2026 · 53 KB

    First release on this site.

How to use

Drag the EA onto the chart of the symbol and timeframe you want, then enable Algo Trading. The EA checks signals on closed bars, once when a new bar opens, while the trailing stop runs on every tick.

Set Period_1 and Period_2 to different values, and set StopLoss and TakeProfit yourself if you want them (in points, not pips). The EA manages only orders of the chart symbol with the configured Magic number. On brokers with market execution it applies SL/TP in a separate step after the order is opened.

Parameters

NameDefaultDescription
Period_120Period of the first MA. The smaller of Period_1 and Period_2 is used as the fast MA and the larger as the slow MA.
Period_222Period of the second MA. If it equals Period_1 the EA refuses to start.
MA_Method_FastMODE_EMAMethod of the fast MA (SMA, EMA, SMMA or LWMA).
MA_Method_SlowMODE_EMAMethod of the slow MA (SMA, EMA, SMMA or LWMA).
MA_Price_FastPRICE_CLOSEApplied price for the fast MA, for example close.
MA_Price_SlowPRICE_CLOSEApplied price for the slow MA, for example close.
MinDiff3Minimum distance between the two MAs, in points, for a cross to count. Filters out marginal crosses.
StopLoss0Stop-loss in points from the entry price. 0 means none.
TakeProfit0Take-profit in points from the entry price. 0 means none.
TrailingStop0Trailing stop distance in points. 0 disables trailing.
TrailingStopTriggerProfit0Profit in points needed before trailing starts. With 0, trailing starts once the profit reaches the TrailingStop distance.
TradeDirectionTRADE_DIRECTION_BOTHDirection allowed for new orders: long only, short only, both, or none (closing and trailing only).
StartHour0Hour (server time) when opening new orders starts, inclusive, 0-23.
StartMinute0Minute when opening new orders starts, 0-59.
EndHour23Hour (server time) when opening new orders ends, inclusive, 0-23. If earlier than the start time, the window crosses midnight.
EndMinute59Minute when opening new orders ends, 0-59.
TradeOnMondaytrueAllow new orders on Monday.
TradeOnTuesdaytrueAllow new orders on Tuesday.
TradeOnWednesdaytrueAllow new orders on Wednesday.
TradeOnThursdaytrueAllow new orders on Thursday.
TradeOnFridaytrueAllow new orders on Friday.
TradeOnSaturdaytrueAllow new orders on Saturday.
TradeOnSundaytrueAllow new orders on Sunday.
CloseTradesOutsideTradingTimetrueIf on, the EA still closes the existing position on an opposite signal outside the trading window (it will not open a new one).
DoTrailingOutsideTradingTimetrueIf on, trailing continues outside the trading window.
Lots0.1Fixed lot size, used when UseMM is false. It must fit the broker min, max and step or the EA will not start.
UseMMfalseCalculate the lot size from free margin instead of using the fixed Lots.
LotsPer100001Lots per 10,000 units of free margin in account currency. Used when UseMM is true.
Slippage3Maximum accepted slippage in points.
OrderCommentaryAdjustable MAComment text put on the orders the EA opens.
DisplayStatusCommentfalseShow the EA status as a text comment on the chart.
Magic19472394Magic number that separates this EA's orders from other orders.

Defaults are the values shipped with the EA, not a recommendation. Results depend on the market and on each account. Past results do not guarantee future results. Trading carries a high risk of loss.

How to install

  1. Download the .ex5 file.
  2. In MT5, choose File > Open Data Folder.
  3. Copy the file into the MQL5\Experts folder.
  4. Right-click Expert Advisors in the Navigator window and choose Refresh (or restart MT5).
  5. Drag it onto a chart, adjust the Inputs, turn on Allow Algo Trading, then click OK.

Description

This EA uses two moving averages, a fast one and a slow one. When the fast MA crosses above the slow MA and the gap is at least MinDiff points it opens a buy; when it crosses below it opens a sell. The method (SMA, EMA and so on) and the applied price can be chosen separately for each line.

On an opposite crossover the EA closes the current position and opens one in the other direction, so it is in the market almost all the time, unless TradeDirection limits it to one side or to no new orders. By default no stop-loss or take-profit is set (both 0), so a position only exits when the lines cross back.

Optional extras are stop-loss, take-profit, trailing stop, limits on the days and hours for new orders, and lot sizing from free margin. It suits trying out different MA crossover set-ups in the Strategy Tester.

Banners from the Exness partner programme

Exness banner: gold spreads*

FXIDTH is an independent IB partner of Exness. This channel is not owned or operated by Exness.*Spreads may fluctuate and widen due to factors including market volatility, news events, market open/close, and others.*Processing times may vary depending on the chosen payment method.