Loading…

Triple Moving Average EA

A bare two-MA crossover trades every crossover regardless of the bigger picture. Adding a third, slower average as a trend reference is the standard next step: the medium MA sitting above or below the slow MA defines the trend, and only fast/medium crosses that agree with it are allowed to open a new position. Crosses against the trend are filtered out rather than traded and reversed. The filter is asymmetric on purpose, the same shape used elsewhere in this catalogue for indicator-filtered systems: it only gates new entries. An existing position is always closed the moment the opposite fast/medium cross appears, regardless of where the medium sits relative to the slow line at that instant - the exit signal firing is itself the trend changing, so re-checking the entry filter before letting the EA leave would trap the position in precisely the moment the exit exists to handle. Stop loss and take profit are fixed pip distances, converted to points per-symbol from the broker's own digit count. Position sizing can run as a fixed lot or, with InpUseRiskSizing on, as a percentage of equity risked to the stop distance, using tick value and tick size rather than a hardcoded contract size so it prices correctly on gold, indices and JPY crosses as well as plain FX pairs. Notes and limitations - The trend filter reduces counter-trend whipsaw; it does not eliminate it. A slow period long enough to filter every loser also filters real entries, and no fixed value is correct for every symbol or timeframe - test before relying on the defaults. - Signals are evaluated once per closed bar, not on every tick. - One position at a time, tracked by InpMagicNumber. It will not manage or interfere with trades opened manually or by another EA. - Requires AutoTrading enabled (IsTradeAllowed() on MQL4, the three-way check described above on MQL5); if trading is disabled the EA logs it and skips the entry. - On an MQL5 netting account specifically: if a foreign-magic position already exists on the chart symbol, this EA refuses to open a new one rather than merge into it - see MQL4 VERSUS MQL5 DIFFERENCES above.

Expert advisor · MT5 · v1.0 · Free

About Triple Moving Average EA

Triple Moving Average EA is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It can size trades from your balance and risk percent. It has 14 settings, such as Fast period, Medium period and Slow period. MQL source code included.

Files in the download: TripleMaEa.ex5, TripleMaEa.mq5, TripleMaEa.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Fast period5Fast MA period
Medium period20Medium MA period
Slow period50Slow MA period (trend reference)
Ma methodMODE_EMAMA method shared by all three lines
Applied pricePRICE_CLOSEPrice the MAs are built from
Stop loss pips50Stop loss distance, in pips
Take profit pips100Take profit distance, in pips (0 = none)
Use risk sizingfalseSize by percent risk instead of a fixed lot
Risk percent1.0Percent of equity risked per trade, when risk sizing is on
Fixed lots0.10Lot size when risk sizing is off, or as a fallback
Magic number20260802Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Moving Average · Trend · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria