Behind MSP Open Alpha #1 - Understanding Trend-Following with Moving Averages

Behind MSP Open Alpha #1 - Understanding Trend-Following with Moving Averages

19 November 2026, 16:05
Christophe Trouillas
0
18

📌  What is the MSP Open Alphas Series?

  • Open source strategies from MetaSignalsPro's agentic research lab MetaMind.
  • Not throwaway demos: each Alpha is serious, tested and robust — it carries a real, measurable edge.
  • But it does not meet our high-performance criteria for the professional MSP range (RiskKILLER AI, GoldZILLA, SquidGRID_AI).
  • So instead of shelving it, we publish it: a strong educational starting point, fully readable and testable.
  • Every rule, input and backtest below comes from the published source code — nothing hidden.


📌  The strategy at a glance (from the source code)


Typology

  • Trend-following EMA crossover system on closed M30 bars, distributed for XAUUSD.
  • Single-position design ("one trade at a time") — no pyramiding.
  • Intraday: entries restricted to a broker server-time window (07:00–19:00 by default).

Entries

  • Evaluated once per new bar (IsNewBar), using only completed bars (CopyBuffer at shifts 1 and 2) — entries never repaint.
  • Buy: fast EMA (20) crosses above slow EMA (50), latest close above both the fast EMA and the 200 EMA trend line.
  • Sell: exact mirror image.
  • Market orders at the current ask/bid.

Exits

  • Stop-loss on every position: fixed percentage of the entry price (1% by default).
  • No take-profit (TP = 0), no signal-based exit: a trade runs until its stop-loss or the daily close.
  • Daily close-all at a configurable server time (20:00 by default), pending orders deleted.

Capital Protection

  • Risk-based sizing: 1% of balance per trade; lot derived from stop-loss distance (tick size, tick value, lot step), clamped to broker limits.
  • Preflight OrderCheck on every order: insufficient margin → new order rejected; no-change SL/TP edits rejected; position-reducing and closing orders always allowed.
  • MagicNumber + comment tags: the EA only manages its own positions and orders.




📌  Q&A — by your experience level

🟢 You are new to algo-trading

Q: Will this EA make me rich quickly?

  • No. It is an educational code sample, not a production-ready signal service.
  • Backtest: +110.73% over ~6.8 years — respectable, not spectacular. That is exactly why it is an Open Alpha.
  • Run it on demo first. Always.

Q: What will it teach me?

  • Subclassing CTrade and routing every order through a preflight (OrderCheck).
  • MagicNumber + comment ownership guards.
  • Position sizing from SL distance + fixed risk percentage.
  • Server-time entry windows (including windows wrapping past midnight) and a once-per-day exit schedule.
  • Repaint-free signals on closed bars (CopyBuffer at shifts 1 and 2).
  • Cleaning up pending orders after a fill via OnTradeTransaction.

🟡 You already run EAs on a live account

Q: How do I test it properly before trusting it?

  • Strategy Tester, "Every tick based on real ticks", realistic spread — not the current one.
  • Several years of data: at least one trending phase + one prolonged range.
  • Check your broker's server clock: the 20:00 daily close and the entry window are in server time.
  • Forward test on demo several weeks: spread widening, requotes, execution delay are where backtest and live differ.

Q: Can it mess with my other trades?

  • No. MagicNumber + comment tags: it only scans and manages its own positions and orders.
  • Works on both hedging and netting accounts.

🔴 You build your own algos

Q: What is worth studying and extending here?

  • The preflight wrapper: margin blocked on new orders, close/reduce always allowed — a clean safety pattern to reuse.
  • The fixed 1% stop + 1% risk sizing: change StopLossPercent and study how the profile degrades.
  • PassesFilters(): an empty entry-filter hook designed for your own conditions.
  • The crossover confirmation (close vs fast EMA + EMA 200): try replacing it with your own filter, then rerun the same backtest window.

Q: What are its structural limits?

  • Ranges sitting entirely above the 200 EMA: the filter stays bullish, whipsaw is not filtered.
  • Late entries: the crossover confirms a move already underway — news spikes are partially missed.
  • Flat every evening: multi-day trends are truncated; re-entry needs a fresh cross.
  • No news awareness: the entry window reduces exposure, it is not a news filter.


📌  Backtest Results — XAUUSD M30, 2020.01.01 – 2026.10.01

Broker: IC Markets (EU) Ltd · USD account · initial deposit 1,000.00 · leverage 1:50 · "Every tick" model · history quality 99% (79,801 bars / 9,542,122 ticks) · all inputs at defaults.


Metric Value
Total net profit +1,107.33 USD (+110.73% on the 1,000 USD deposit)
Profit factor 1.46 (gross profit 3,522.91 vs gross loss −2,415.58)
Win rate 52.80% — 264 of 500 trades (longs 51.45% won, shorts 54.46% won)
Expected payoff +2.21 USD per trade
Max drawdown Balance: 136.08 USD (8.07%) · Equity: 145.25 USD (8.59%)
Recovery factor / Sharpe ratio 7.62 / 4.13
Largest win / largest loss +105.28 / −51.81 USD (avg win +13.34 vs avg loss −10.24)
Max consecutive losses 8 trades (−28.41 USD total)
Average holding time 6h 08m (min 5m 40s, max 34h 30m)
Margin level at end 1,046.29% (low margin usage thanks to 1% risk sizing)


What the numbers show:

  • Positive expectancy: PF 1.46, avg win (+13.34) > avg loss (−10.24) — payoff asymmetry, not a high win rate.
  • Balanced long/short (276 long / 224 short, both ~52–54% winners) — not a one-directional curve-fit.
  • Drawdown in single digits (8.59% of equity) over ~6.8 years — consistent with 1% sizing and the daily close-all.
  • AHPR 1.0016 / GHPR 1.0015, LR correlation 0.96: steady growth, not one lucky spike.
  • 8 consecutive losses happened — plan your psychology and your capital for it.

Note: these results come from one broker, one symbol, one period and one set of inputs, on a 1,000 USD demo-style backtest. They show how the code behaves in the Strategy Tester — they are not a promise of future results (see "What this EA is and what it is not" below).




📌  Setup in 4 steps

  • Attach to an XAUUSD M30 chart (it trades the chart's symbol/timeframe; distributed for XAUUSD M30).
  • Defaults are the tested values — change them only after you re-tested.
  • Hedging or netting account: both supported.
  • Broker with clean XAUUSD M30 history + VPS recommended (e.g. IC Markets).


What this EA is and what it is not

  • This EA is an educational algo, not a production-ready algo
  • This EA is part of the MSP Open Alpha series: open source codes by Meta Signals Pro - Research Lab
  • It is intentionally simple: it is a learning and experimentation tool, not a fully optimized trading system.

  • If you want professional algos, explore MetaSignalsPro products on the MQL5 marketplace


📌 Want to get all MSP EA Perfs and launches?

💪 Join our MSP Public Group on MQL5



📚 Continue Your Learning


💪 Join Our MQL5 Community

💪 Join our MSP Public Group

💪 Join our dedicated Public Group on algos: