Blog / Strategy
Strategy

Sequential Record Imbalance

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 Sequential Record Imbalance strategy is a single-timeframe, trend-following expert advisor (EA) for MetaTrader 5 that measures market drift using record statistics — the mathematical theory of running maxima and minima — rather than a conventional indicator, chart pattern, or support/resistance level. Its only supporting indicator is the Average True Range (ATR), a volatility gauge used purely to size stops and targets. The core signal comes from counting how often price sets new highs versus new lows inside a rolling window of bars.

The idea rests on two classical results from probability theory. First, within any sequence, a bar is an upper record when its high exceeds every earlier high in the window, and a lower record when its low undercuts every earlier low. For a market with no directional bias (a "driftless" random walk), upper and lower records occur symmetrically, so their difference averages to zero. Genuine directional drift — a persistent tendency for price to move one way — is what breaks that symmetry: an uptrend renews highs far more often than lows, and a downtrend does the reverse. The strategy turns this imbalance into a normalized drift score and then measures how unusual that score is compared with the instrument's own recent behaviour.

This EA is best understood as a learning tool for traders who want to study trend-detection from a statistics-first angle. It suits those curious about distribution-free, self-calibrating signals and who already understand basic MT5 order handling. It is designed for trending market conditions and, like all trend-following systems, is expected to struggle in choppy, range-bound phases. Treat it as a framework for analysis and experimentation, not as a shortcut to results.

How It Works

The strategy evaluates signals only when a new bar has fully closed, which avoids "repainting" (signals that change as the current candle forms). Each completed bar is added to rolling arrays of highs, lows, and closes, and the logic then proceeds as follows.

sequential record imbalance MT5 EA
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
Window 40 15 120 Number of completed bars in the rolling record window used to count upper and lower records.
ScoreLookback 60 20 200 How many past drift scores are used to standardize the current score into a z-score.
EntryZ 1.20 0.50 3.00 Z-score threshold required to trigger an entry; higher values demand more statistically extreme drift.
ExitZ 0.30 0.00 1.50 Z-score level at which an open position is closed because record renewal has stalled.
AtrPeriod 14 7 28 Number of bars used to calculate the ATR that sizes stops and targets.
SlAtrMult 1.80 0.50 4.00 Stop-loss distance expressed as a multiple of ATR.
TpAtrMult 2.80 0.50 6.00 Take-profit distance expressed as a multiple of ATR.
BreakevenAtr 1.00 0.00 3.00 Profit distance (in ATR multiples) at which the stop is moved to breakeven; 0 disables it.
Lots 0.10 0.01 1.00 Fixed trade volume in lots.
sequential record imbalance MT5 EA — MQL5 source code

Recommended Chart Settings

Because the record-imbalance method is designed to be distribution-free and self-calibrating, it is not locked to a single symbol. That said, trend-following logic generally behaves best on liquid instruments with sustained directional moves. A sensible starting point for study is a major forex pair such as EUR/USD on an intraday-to-swing timeframe like H1 or H4, where individual bars carry meaningful record information and noise is lower than on very short timeframes.

Keep in mind that results will vary considerably across different symbols, timeframes, and market conditions. Always test any configuration on historical data and a demo account before drawing conclusions, and re-check the Window and ScoreLookback values whenever you change timeframe, since they define the memory of the system in bars.

How to Install on MetaTrader 5

What to Consider Before Using This EA

The main strength of this approach is its theoretical independence from any single indicator. Record statistics are distribution-free, meaning the record-counting logic does not assume prices follow a particular statistical shape. The z-score standardization adds a genuinely adaptive layer, so the same settings can respond to very different instruments without manual retuning. Pairing entries with ATR-based stops and a breakeven mechanism also gives the system a disciplined, volatility-aware risk framework.

There are important limitations to weigh honestly. Like every trend-following method, Sequential Record Imbalance is built to profit from persistence, so it may underperform in ranging or mean-reverting markets, where drift is weak and records flip back and forth, producing whipsaw entries and repeated small losses. The z-score also needs a warm-up period before it can fire, so it does nothing until enough scores accumulate. During abrupt regime changes — for example, a sharp reversal after a long trend — the exit logic may lag, since it waits for record renewal to stall rather than reacting instantly to price. Finally, the fixed Lots sizing does not scale to account equity, and default thresholds are starting points, not optimized values.

Approach this EA as a study of how drift can be detected statistically, and validate every assumption yourself before relying on it.

Risk Management Tips

Sound risk management matters far more than any single entry rule. Consider these general principles as you study this EA:

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

← Back to Blog