Golden Cross Trend Filter (50/200 SMA on daily closes)

Golden Cross Trend Filter (50/200 SMA on daily closes)
Download ALL MT5 experts (1777)
YouTube Video Thumbnail



Similar MetaTrader Tools

Golden Cross Trend Filter (50/200 SMA on daily closes)

Info

The Golden Cross Trend Filter (50/200 SMA on daily closes) is a Expert Advisor for MetaTrader 5 that the golden cross is one of the best-known trend rules: stay in the market while the 50-day simple moving average of daily closes is above the 200-day average, and step aside when it is below (the "death cross"). This Expert Advisor implements exactly that rule, so it can be tested and run on any symbol with daily history.

Usage

This tool is typically used for trend following strategies across multiple currency pairs.

Platform

This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use Golden Cross Trend Filter (50/200 SMA on daily closes)

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

The Golden Cross is one of the best-known trend rules: stay in the market while the 50-day simple moving average of daily closes is above the 200-day average, and step aside when it is below (the "death cross").

Typical Use Case

This Expert Advisor excels in trend following on MetaTrader 5.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.

Description & Settings

Related: Moving Average Crossover Expert Advisor for Gold (XAUUSD) - another powerful expert for MetaTrader 5 traders.



Also recommended: EMA Trend Cross Strategy for XAUUSD M30 - similar expert with strong performance on MetaTrader 5.

The Golden Cross is one of the best-known trend rules: stay in the market while the 50-day simple moving average of daily closes is above the 200-day average, and step aside when it is below (the "death cross"). This Expert Advisor implements exactly that rule, so it can be tested and run on any symbol with daily history.

How it works.
The averages are always taken from the last
completed
daily bar (shift 1), never from the bar that is still forming, so a decision cannot change during the day and there is no look-ahead in the Strategy Tester. Once per new D1 bar the EA compares the two averages: if SMA(fast) > SMA(slow) it wants to be long, otherwise flat; with InpAllowShort enabled it goes short while SMA(fast) < SMA(slow). There is no stop-loss and no take-profit, because the rule itself is the exit.

Session handling.
On many CFDs the new daily bar opens while the market is still closed (for example index CFDs at midnight server time). The EA therefore checks the symbol's trade sessions and, if the market is closed or an order is rejected, retries on the next ticks of the same day. Attach it to an
H1 (or lower) chart
; in the tester use H1 with "Open prices only" or "Every tick", because a D1 chart in "Open prices only" mode receives a single tick at midnight.

Test on a US500 CFD: the rule worked, the financing did not

US500 CFD, H1, January 2015 to November 2026, 10,000 USD, 50% notional, long only. The EA entered and exited on the same dates as the well-known golden and death crosses of the S&P 500 (April 2016, December 2018, March 2019, March 2020, July 2020, March 2022, January 2023, April 2025, July 2025). The price movement of these trades earned money, but the long positions were held for up to 954 days and the daily swap cost more than twice the price gain:

Trade

Days held

Price profit

Swap

Net

2016.04 – 2018.12, 2.3 lots

954

+1,389.84

−4,472.90

−3,083.06

2019.03 – 2020.03, 1.2 lots

367

−403.32

−898.62

−1,301.94

2020.07 – 2022.03, 0.8 lots

609

+884.72

−992.67

−107.95

2023.01 – 2025.04, 0.6 lots

805

+813.80

−983.25

−169.45

2025.07 – 2026.11, 0.4 lots

499

+561.16

−408.47

+152.69

Total

+3,246.20

−7,755.91

−4,509.71

Two notes on this test. First, the swap was a constant 2.04 USD per lot per day in every trade: the Strategy Tester applies the symbol's
current
swap to the whole history, so in the early years, when the index was near 2,100 instead of 7,500, the cost is overstated relative to the position value. Second, even at today's price that swap is close to 10% per year of the position value, which is enough to remove most of the return of a slow trend rule. On the S&P 500 price index itself (1993–2026, no costs) the same rule earned a CAGR of 8.41% against 8.93% for buy and hold, with a maximum drawdown of −33.9% instead of −56.8%. The difference between the two results is the cost of holding a CFD for months. Check the swap of your symbol before using a long-holding EA.

Inputs

InpFastPeriod
(50) – fast SMA period, in daily bars.

InpSlowPeriod
(200) – slow SMA period, in daily bars; must be greater than the fast period.

InpAllowShort
(false) – also hold a short position while the fast SMA is below the slow SMA.

InpNotionalPct
(50) – position value as a percentage of the account balance; set 0 to use the fixed lot instead.

InpFixedLot
(0.10) – lot used when InpNotionalPct = 0.

InpMagic
– magic number, so the EA manages only its own positions.

InpDeviation
(50) – maximum slippage in points.

Historical results for this exact rule and symbol. They do not guarantee future results.

You may also like: Fx Craft Example EA: MA Cross Strategy Explained - excellent alternative for expert users on MetaTrader 5.

Source Code

#property copyright "RobotFX"
#property version   "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#include <Trade\Trade.mqh>
input int    InpFastPeriod  = 50;
input int    InpSlowPeriod  = 200;
input bool   InpAllowShort  = false;
input double InpNotionalPct = 50.0;
input double InpFixedLot    = 0.10;
input long   InpMagic       = 205020;

.......

Leave your opinion, ask a question, share some knowledge

⚠ Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.