Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

Edge Drift Detector - script for MetaTrader 5

Real author
Published by:
Cristian David Castillo Arrieta
Cristian David Castillo Arrieta
Finance and International Business professional with a specialization in Financial Management. Self-taught MQL5 and Python developer focused on algorithmic trading, multi-asset portfolio construction, and quantitative risk management.
Views:
24
Published:
\MQL5\Script\
DriftExport.mq5 (6.86 KB) view
EdgeDrift.mq5 (52.59 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Edgedrift


A live Expert Advisor can stay in profit long after its edge has gone. The Edge Drift Detector answers one question with a statistical test: do the live closing deals still come from the same distribution as the backtest, or has the average result per deal fallen toward zero?

The script reads two CSV files and prints a full report in the Experts tab:

A live Expert Advisor can stay in profit long after its edge has gone. The Edge Drift Detector answers one question with a statistical test: do the live closing deals still come from the same distribution as the backtest, or has the average result per deal fallen toward zero?

The script reads two CSV files and prints a full report in the Experts tab:

  • CUSUM edge-loss detector: an alarm threshold calibrated by bootstrap from the backtest deals, with a false-alarm rate you choose over a planned monitoring horizon.
  • Drift start: the deal and date after which the drift most likely began.
  • Two-horizon check: bootstrap tail probabilities for the last 20 and the last 100 deals.
  • Expectancy decomposition: the change in expectancy split into win-rate, win-size, and loss-size effects.
  • Symbol mix check: a warning when the live account trades a different mix of instruments than the baseline, since per-lot results of different symbols are not comparable.
  • Detection delay: the median number of deals needed to confirm a complete loss of edge for this strategy.
  • Edge Health Score (A+ to F) and a CONTINUE, WATCH, REDUCE, or SUSPEND verdict with written recommendations.

Input. No code changes are needed. Backtest the Expert Advisor, right-click the Backtest results, choose Report, and save it as HTML in the common Files folder. Then run EdgeDrift.mq5 on the live account with the Expert Advisor's magic number. The script finds the newest ReportTester*.html file by itself and reads the live deals from the account history. On the first run, before any report exists, it prints these steps and analyzes built-in demonstration data. Two alternatives are available: a CSV baseline or live file, and a baseline taken from the same account before a chosen date. DriftExport.mq5 is an optional helper that writes the live deals to CSV when the account runs on another terminal.

Files. Both scripts go to MQL5\Scripts\EdgeDrift. The attached MQL5.zip already has this structure.

Parameters. InpBaseSource selects a tester report, a CSV file, or the account history. InpLiveSource selects the account history or a CSV file. InpMagic, InpSymbol, and InpLiveFrom filter the deals. InpMaxMixGap sets the symbol mix difference that triggers a warning. InpHorizon sets the planned monitoring horizon in deals. InpAlpha sets the false-alarm probability over that horizon. InpShortWindow and InpLongWindow set the two windows. InpBootstrap and InpSeed control the resampling, which is reproducible. InpPerLot normalizes every result to one lot. The score weights, the healthy tail level, and the grade boundaries are all inputs.

Buy GBPJPY Every Monday. That's the Whole Strategy. Buy GBPJPY Every Monday. That's the Whole Strategy.

A free, fully open EA: buy GBPJPY every Monday at 11:00 server time (04:00 New York), close at 23:00. Stays profitable in backtest with the entry anywhere from 09:00 to 13:00. Attach to GBPJPY M1.

Market session indicator lines for scalpers Market session indicator lines for scalpers

Quickly view each and every individual market's open and close times. Very important for short term scalping. I own the copyright, if anyone modifies or uses this it must stay free. Comments and feedback welcome.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.