Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.
What Is This Strategy?
The First Passage Drift Bias strategy is a directional trend-detection Expert Advisor (EA) for MetaTrader 5 built on first-passage-time theory, a concept borrowed from the mathematics of stochastic processes rather than from any conventional chart indicator or candlestick pattern. Instead of reading moving averages or oscillators, it treats the closing-price series as a random path and measures how long that path takes to travel a fixed distance up versus down. The core idea is that a truly efficient, driftless market reaches an equal-sized up-barrier and down-barrier in roughly the same amount of time — while a market under genuine directional pressure reaches the aligned barrier sooner. That timing gap becomes the trading signal.
In plain terms, the strategy is designed for markets that may be developing a directional drift — a subtle, persistent lean in one direction that isn't always visible in raw price movement. Because the signal is built from the timing of price moves rather than their raw size, it is intended to distinguish a steady one-way grind (a strong, tradeable bias) from a violent spike that quickly retraces (noise). This makes it conceptually different from ordinary momentum systems.
As a learning tool, First Passage Drift Bias is best suited to intermediate and advanced traders who want to study how statistical models of drift can be turned into entry and exit rules. It is not a "set and forget" money machine — it is an analytical framework worth studying to understand how first-passage timing, robust volatility scaling, and censoring can be combined into a systematic trading model.
How It Works
The strategy processes one newly-closed bar at a time and rebuilds its statistic on each new bar. Here is what happens step by step:
- Building the barrier: The EA first measures a robust volatility scale
s, defined as the median of the absolute bar-to-bar close changes across its buffer. Using the median (rather than the average) keeps the scale from being distorted by a single outlier bar. The displacement barrier is then set toθ = ThresholdMult × s. - Measuring first-passage times: For each of the oldest
AnchorCountcloses that still have a full forward window, the strategy scans forward up toHorizonbars. It records the first bar at which price rises by+θ(the up-barrier hit time,t_up) and the first bar at which price falls by−θ(the down-barrier hit time,t_dn). - Censoring quiet anchors: If a barrier is never reached within the horizon, its hit time is censored to
Horizon + 1. This symmetric penalty keeps the estimator fair and automatically pushes the signal toward zero in quiet regimes where few anchors resolve — the correct "low-confidence" behavior. - The bias statistic: The strategy computes
A = (mean_t_dn − mean_t_up) / (mean_t_dn + mean_t_up), a value between −1 and +1. WhenA > 0, the up-barrier is being reached faster, which the strategy reads as upward bias. WhenA < 0, the down-barrier is reached faster, indicating downward bias. - Regime gate: Before trading, the strategy requires that a healthy share of anchors actually reached a barrier (at least
AnchorCount / 4, or 4, whichever is larger). If too few resolved, the barrier is too large for current volatility and the signal is treated as untrustworthy — no trade. - Entry signal: When there is no open position, the regime gate passes, and
|A|exceeds theBiasEntrythreshold, the strategy signals a market entry in the direction ofA— a buy whenAis positive, a sell whenAis negative. - Stop-loss logic: Risk is sized from the Average True Range (ATR), a common volatility measure. The stop-loss is placed
AtrSlMult × ATRaway from entry, so it widens in volatile markets and tightens in calm ones. - Take-profit logic: The take-profit is placed
AtrTpMult × ATRfrom entry. With the default multipliers (2.0 stop, 3.0 target), this frames each trade around a reward-to-risk ratio of roughly 1.5-to-1. - Active exit: The strategy holds only one position at a time. If the bias flips meaningfully against an open trade — past half of the
BiasEntrythreshold in the opposite direction — it closes the position early, on the logic that the temporal edge that justified the trade has disappeared. Otherwise the trade is managed by its stop-loss or take-profit.

Strategy Parameters
| Parameter | Default | Min | Max | Description | ||
|---|---|---|---|---|---|---|
| Lots | 0.10 | 0.01 | 1.00 | Trade size in lots for each position opened. | ||
| AnchorCount | 40 | 15 | 100 | Number of past closes used as first-passage anchors — the sample size for the bias estimator. | ||
| Horizon | 12 | 4 | 40 | Forward horizon, in bars, over which each anchor's up- and down-barrier may be reached. | ||
| ThresholdMult | 1.50 | 0.50 | 4.00 | Barrier size θ as a multiple of the median absolute one-bar close change. | ||
| BiasEntry | 0.30 | 0.05 | 0.70 | Minimum hitting-time asymmetry ` | A | ` required to open a trade. |
| AtrPeriod | 14 | 5 | 40 | ATR period used for stop-loss and take-profit sizing. | ||
| AtrSlMult | 2.00 | 0.50 | 6.00 | Stop-loss distance as a multiple of ATR. | ||
| AtrTpMult | 3.00 | 0.50 | 8.00 | Take-profit distance as a multiple of ATR. |

Recommended Chart Settings
The First Passage Drift Bias EA is symbol- and timeframe-agnostic by design — it derives everything from raw OHLC (open, high, low, close) data and runs on whatever single timeframe you attach it to. That said, the default parameters (40 anchors, a 12-bar horizon) suit an intraday-to-swing rhythm, which makes the H1 (1-hour) timeframe on a major, liquid forex pair such as EUR/USD a sensible starting point for study. Higher timeframes like H4 will produce fewer, slower signals; lower timeframes like M15 will produce more frequent but noisier ones.
Because the barrier scales to each market's own median volatility, the model adapts across instruments, but that does not mean it behaves identically everywhere. Results will vary considerably across symbols, timeframes, and changing market conditions. Always test any configuration on historical data and a demo account before drawing conclusions.
How to Install on MetaTrader 5
- Download the .ex5 file from the link below
- Copy it to your MT5
MQL5\Expertsfolder - Restart MetaTrader 5 or refresh the Navigator panel
- Drag the EA onto a chart matching the recommended symbol and timeframe
- Configure the input parameters and enable Algo Trading
What to Consider Before Using This EA
Strengths of the approach. The most interesting quality of First Passage Drift Bias is that it measures timing rather than magnitude. A steady, one-directional grind reaches its aligned barrier quickly from nearly every anchor, producing a large |A|, whereas a sharp move that later retraces reaches both barriers at similar times and scores close to zero. Because the statistic is built from ordinal hit-times rather than return sizes, it is naturally robust to fat-tailed single-bar spikes and is invariant to the absolute price level. The median-based volatility scale and the censoring mechanism further add discipline, automatically damping the signal when the market is quiet.
Known limitations. First-passage theory assumes a reasonably well-behaved path, and real markets frequently violate those assumptions — gaps, news shocks, and sudden volatility regime shifts can all distort the estimate. Because the model only ever holds one position and enters at market, it can miss opportunities during fast, one-way runs and can be whipsawed when the bias hovers near the entry threshold. The active-exit rule that closes on a bias flip protects against staying wrong, but it can also exit a good trade prematurely during normal pullbacks.
Where it may underperform. Choppy, mean-reverting, range-bound conditions are the hardest environment for any drift detector: barriers get hit in both directions at similar times, |A| stays small, and the strategy will mostly stand aside — which is correct behavior, but means long idle stretches. Conversely, in a violently volatile market the ATR-based stops can become very wide, increasing the monetary risk per trade. This is a framework to study and understand, not a guaranteed edge.
Risk Management Tips
Sound risk management matters far more than any single entry signal. Keep these general principles in mind as you study this strategy:
- Risk a small, fixed fraction per trade. A widely taught guideline is to risk no more than 1–2% of your account balance on any single position. Size your
Lotsso that the ATR-based stop-loss distance corresponds to that fraction, not the other way around. - Start on a demo account. Run the EA on a demo or paper account first, across different market conditions, until you understand how it behaves before considering any live capital.
- Understand drawdown. Every systematic strategy experiences losing streaks. Study the historical drawdown — the peak-to-trough decline in equity — so that a normal losing run does not surprise you into abandoning a plan or over-leveraging.
- Respect leverage. Leverage amplifies both gains and losses. Use the lowest leverage that lets you implement your plan comfortably.
- Diversify and monitor. Avoid concentrating all risk in one instrument or one strategy, and check that the EA is behaving as expected, especially around high-impact news events.
Risk management is what allows you to survive long enough to learn. Treat it as the first priority, not an afterthought.
Risk Warning
Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.
Downloads
- Expert Advisor: FirstPassageDriftBias.ex5 (0 downloads)
- Source Code: FirstPassageDriftBias.mq5 (0 downloads)
- Documentation: FirstPassageDriftBias.pdf (0 downloads)