A strategy is tested at a risk, say 1% per trade, and then run with a fixed lot. From that moment the risk is no longer 1%. The loss at the stop loss is lot × stop distance, and the balance it is measured against changes after every trade. With an ATR stop, the stop distance also follows the market's volatility. The terminal shows lots, not risk, so the drift goes unnoticed until one loss is much bigger than expected.

This script rebuilds, from the account's deal history, the risk of every trade:
It then compares each Expert Advisor (magic number and symbol) with itself: the median risk of its first trades (the tested risk, unless you enter it) against its last trades, the largest risk, how many trades were above a multiple of the tested risk, trades without a stop loss, and the lot that would carry the tested risk at today's balance with the last trade's stop distance.
Example: what a fixed lot did on gold. A fixed 0.02-lot breakout EA with a 2 × ATR stop, XAUUSD H1, 2023 to October 2026, $10,000 (Strategy Tester):
| Year | Median risk per trade | Median stop distance | Median balance |
|---|---|---|---|
| 2023 | 0.18% | $8.7 | $9,645 |
| 2024 | 0.24% | $11.4 | $9,516 |
| 2025 | 0.45% | $20.3 | $9,066 |
| 2026 | 0.88% | $38.6 | $8,827 |
The lot never changed and the balance hardly moved, yet the risk per trade grew five times, because the stop distance grew with gold's price and volatility. The largest single risk was 5.77% of the balance (31 times the starting risk), in the volatile days of early February 2026. 453 of the 1,044 trades were above twice the starting risk.
How it was checked. A test EA recorded, at every entry, its balance and lots × contract size × stop distance. The script's numbers matched all 1,044 trades: balance before entry exact, risk within one cent (OrderCalcProfit rounds to cents), and the stop-loss source right for every trade, including 104 trades that opened without a stop and set it on the next tick.
Output
Inputs
In the Strategy Tester. RiskDrift.mqh also works inside an Expert Advisor, so a backtest can report how its own risk drifted:
#include "RiskDrift.mqh"
double OnTester()
{
CRiskDrift rd;
if(rd.Load(_Symbol, -1, 0, D'2100.01.01'))
{
rd.SetTested(0.0, 20);
rd.Report(2.0);
}
return 0.0;
} Limits
The script only reads the history. It never places, modifies or closes an order.
Previous Day High, Low and Close Levels
Draws the previous day High, Low and Close as horizontal levels on the chart, with optional history for several past days, extension of today's levels to the right and price labels.
Position Tool - TradingView-style Long/Short position calculator
TradingView-style Long/Short position tool for MT5: drag the Entry, Stop and Target lines and get lot size, risk, reward, R:R and margin instantly.
Spread and Daily ATR Risk Meter HUD
Compact zero-buffer MetaTrader 5 on-chart HUD displaying live Spread in points and pips, Daily ATR(14) range consumption percentage, broker Stops/Freeze levels, and 1R lot size.
Round-Number / Psychological Level Magnet
Auto-scaled round-number grid for any symbol — big figures and half levels drawn to the right spacing whether you're on EURUSD, USDJPY, XAUUSD or an index, plus a live "distance to nearest magnet" readout.