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
| Setting | Default | What it does |
|---|---|---|
| Fast period | 5 | Fast MA period |
| Medium period | 20 | Medium MA period |
| Slow period | 50 | Slow MA period (trend reference) |
| Ma method | MODE_EMA | MA method shared by all three lines |
| Applied price | PRICE_CLOSE | Price the MAs are built from |
| Stop loss pips | 50 | Stop loss distance, in pips |
| Take profit pips | 100 | Take profit distance, in pips (0 = none) |
| Use risk sizing | false | Size by percent risk instead of a fixed lot |
| Risk percent | 1.0 | Percent of equity risked per trade, when risk sizing is on |
| Fixed lots | 0.10 | Lot size when risk sizing is off, or as a fallback |
| Magic number | 20260802 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Moving Average · Trend · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code