Skip to content
Forex Indicator System Thailand
Back to marketplace
UtilityUtility

MA Trailing Stop (moving average trailing stop)

A tool that trails the stop-loss of open positions along a moving average, with an on/off button on the chart

Download this EA for free

Download right away. Nothing to fill in.

Version
1.02
Published
11/21/2026
File size
69 KB

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

Version history

  1. 1.02Current11/21/2026 · 69 KB

    First release on this site.

How to use

Attach the EA to a chart and turn on Algo Trading. EnableTrailingParam defaults to false, so at start the EA moves nothing. Press the button on the chart panel to start trailing, or set EnableTrailingParam to true before use.

MAPeriod, MAMethod and MAAppliedPrice define the MA, and Shift picks which bar's MA value to use (0 = the current bar, whose value can change during the bar). Before using it on a live account, check OnlyCurrentSymbol, OnlyType, UseMagic and UseComment so you know exactly which positions the EA will pick up.

Notifications work when EnableNotify is on and one of SendAlert, SendApp or SendEmail is chosen. The source includes the bundled MQLTA Utils.mqh file at compile time. Press Esc on the chart to remove the EA.

Parameters

NameDefaultDescription
MAPeriod25Moving average period.
MAShift0Shift of the MA line (number of bars).
MAMethodMODE_SMAMA calculation method (SMA, EMA, SMMA, LWMA).
MAAppliedPricePRICE_CLOSEPrice used for the MA (e.g. Close).
Shift0Which bar's MA value to use (0 = the current bar).
ProfitPoints0Start trailing when the position has this many points of profit. 0 = ignore profit.
OnlyCurrentSymboltruetrue = manage only positions on the chart's symbol. false = include positions on every symbol in the account.
OnlyTypeAllPosition type to manage: all, buy only or sell only.
UseMagicfalsetrue = manage only positions whose Magic Number matches MagicNumber.
MagicNumber0Magic Number used as a filter (when UseMagic is true). 0 is what manually opened positions carry.
UseCommentfalsetrue = manage only positions whose comment contains CommentFilter.
CommentFilterText that must appear in the position's comment (when UseComment is true).
EnableTrailingParamfalsetrue = start trailing as soon as the EA starts. false = wait for the panel button.
EnableNotifyfalsetrue = turn the notification feature on.
SendAlerttruetrue = show a popup alert in the terminal.
SendAppfalsetrue = send a notification to the MetaTrader mobile app (set up your MetaQuotes ID first).
SendEmailfalsetrue = send an email (set up SMTP in the terminal first).
ShowPaneltruetrue = show the control panel on the chart, with a button to switch the EA on and off.
ExpertNameMQLTA-FRTSPrefix for the names of the panel objects on the chart.
Xoff20Horizontal distance of the panel from the chart corner.
Yoff20Vertical distance of the panel from the chart corner.
ChartCornerCORNER_LEFT_UPPERChart corner where the panel is placed.
FontSize10Font size of the panel.

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

MA Trailing Stop moves the stop-loss of open positions to the value of a moving average. It opens no new trades and does not touch take-profit. It uses the MA you set (period, method, applied price and shift) on the chart's timeframe, and moves the stop-loss only in the direction that locks in more profit: up for buys, down for sells.

The MA value must be at least the broker's minimum stop distance away from the current price, otherwise the stop is not moved. Set ProfitPoints to start trailing only once a position has that many points of profit.

Filters decide which positions are managed: only the chart's symbol, buy or sell type, Magic Number and comment text. There is a panel on the chart with a button to start or stop trailing, and notifications when a stop-loss is moved.

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.