Blog / Strategy
Strategy

Mean Crossing Cadence Regime

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 Mean Crossing Cadence Regime strategy is a regime-switching Expert Advisor (EA) for MetaTrader 5 built around a single, unusual measurement called the mean-crossing cadence — the rate at which price crosses back and forth over its own recent average. Rather than borrowing from any named indicator, chart pattern, or popular methodology, it draws on a concept from signal-processing theory known as level-crossing analysis (Rice's formula) and applies it directly to the closing-price series. In plain terms, it counts how often price flips from one side of its local mean to the other and uses that count to decide whether the market is currently "bouncy" (mean-reverting) or "sticky" (trending).

Because the same statistic both classifies the market and points to a trade direction, the strategy is entirely self-arbitrating: one number chooses the playbook, and price's position relative to its mean chooses the side. When crossings are frequent, the strategy treats large deviations as temporary and fades them back toward the mean. When crossings are rare, it treats a fresh crossing as the ignition of a new directional leg and follows it. Volatility is measured using the mean-absolute-deviation (MAD) of the window and the Average True Range (ATR), so stops and targets adapt as market conditions breathe.

This EA is best viewed as a learning tool for traders who want to understand adaptive, regime-aware logic and how a market's oscillation frequency can inform tactics. It is designed with FX majors and metals on M5–H1 timeframes in mind, but it locks to no specific timeframe. It is not a shortcut to results and is not suitable as a set-and-forget system without study, testing, and supervision.

How It Works

The strategy acts once per newly closed bar on the chart's timeframe. On each closed bar it recalculates its window statistics and then evaluates whether the current regime is mean-reverting or trending.

Mean-reverting regime — fade the stretch (target the mean):

Trending regime — follow a fresh mean crossing:

Exit and position management: Every trade carries a hard stop-loss and take-profit at the moment it is opened, so the broker-side orders manage all exits. The EA holds one position per magic number at a time and skips new entries when the current spread exceeds MaxSpreadPoints, helping avoid entries during unusually wide, illiquid conditions.

mean crossing cadence MT5 EA
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
LookbackN 40 15 90 Number of closed bars used to compute the mean and the crossing cadence κ.
CadenceThreshold 0.35 0.15 0.60 κ at or above this value = mean-reverting regime; below = trending regime.
EntryZ 1.6 0.8 3.0 Fade trigger: how many mean-absolute-deviation units price must be stretched from the mean.
AtrPeriod 14 5 30 Lookback period for the ATR used to size stops and targets.
AtrStopMult 2.0 0.5 4.0 Stop-loss distance as a multiple of ATR.
TrendTpMult 2.5 0.5 5.0 Trend-regime take-profit distance as a multiple of ATR beyond entry.
MinRewardRisk 0.7 0.3 3.0 Rejects fades whose mean target is closer than this fraction of the ATR stop distance.
MaxSpreadPoints 60 5 300 Skip new entries when the current spread (in points) exceeds this value.
Lots 0.10 0.01 1.0 Fixed trade volume in lots.
Magic 5417 0 9,999,999 Magic number identifying this EA's positions.
mean crossing cadence MT5 EA — MQL5 source code

Recommended Chart Settings

The Mean Crossing Cadence Regime EA was designed with FX majors and metals (for example EURUSD, GBPUSD, or XAUUSD) in mind, on timeframes from M5 through H1. Because the cadence statistic and MAD/ATR yardsticks are self-scaling, the logic is not hard-wired to a single timeframe — it runs on whatever chart period you attach it to. That said, different symbols and timeframes will produce very different crossing frequencies, so the CadenceThreshold that separates ranging from trending behavior may need to be re-tuned per market. Results will vary across different market conditions, brokers, and spread environments, and any settings should be validated on your own data before use.

How to Install on MetaTrader 5

What to Consider Before Using This EA

The main conceptual strength of this approach is that it does not assume the market is always trending or always ranging. By reading the mean-crossing cadence, it attempts to adapt its tactics to whichever regime is present, and it uses robust, distribution-free volatility measures (MAD and ATR) rather than assuming prices are normally distributed. Because every trade is opened with a defined stop and target, risk on each position is bounded from the outset.

There are, however, meaningful limitations to understand. Regime classification from a single statistic is inherently noisy: κ can sit near the threshold and flip between regimes on consecutive bars, producing whipsaw between fade and follow logic. The strategy also acts only on closed bars, so it may enter after a portion of a move has already occurred. Mean-reversion fades can suffer during strong, sustained trends where price stretches far beyond the mean and keeps going, while the trend-following branch can be caught out during choppy, false breakouts of the mean. Fixed-lot sizing does not scale risk to account equity or volatility, and the spread filter, while helpful, does not protect against slippage during news. As with any strategy, historically favorable behavior in one market or period may not repeat in another.

Risk Management Tips

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