Blog / Strategy
Strategy

Variance Ratio Trend 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 Variance Ratio Trend Regime strategy is a regime-gated momentum system for MetaTrader 5 built around the Lo & MacKinlay Variance Ratio test — a classic statistical measure of whether price movement is a random walk or shows exploitable structure. Unlike a moving-average crossover or an oscillator, the variance ratio is not a charting indicator at all; it is a formal test that tries to answer one precise question before any trade is considered: is this market currently trending, or is it just noise?

The core idea comes from a simple property of random walks. For a purely random price series, the variance of returns grows in a straight line with the holding horizon — the variance of returns measured over five bars should be about five times the variance measured over one bar. When you divide the two, you get a number close to 1. When shocks persist (a trending regime), the ratio climbs above 1. When shocks reverse (a choppy, mean-reverting regime), it falls below 1. The Variance Ratio Trend Regime strategy only looks for entries when this ratio confirms a trending regime, then uses a short-term drift measurement and a continuation candle to pick direction.

This makes it a useful learning tool for anyone studying trend-following and momentum trading, statistical filters, and the concept of "market regimes." It is designed for liquid instruments — FX majors, indices, or metals — on intraday timeframes such as M15 to H1. It suits traders who want to understand why a momentum system might stand aside in a sideways market rather than one who simply wants a set-and-forget robot. Treat it as a study of how a statistical gate can filter naive momentum, not as a shortcut to results.

How It Works

The strategy evaluates conditions once per newly closed bar on the chart's primary timeframe. It never acts on a partially formed bar, which reduces noise and repainting concerns. Here is how the logic flows:

Because every calculation uses the chart's own symbol and timeframe, the strategy runs on whatever chart you attach it to. Nothing is hard-coded to a single market.

variance ratio trend regime EA
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
VrWindow 80 40 200 Number of closes (rolling sample of 1-period log returns) used to estimate the variances.
VrLag 5 2 15 Horizon q of the variance ratio — how many bars a "shock" is measured over.
VrThreshold 0.15 0.0 1.0 Minimum (VR − 1) required to classify the regime as "trending" and allow trades.
MomentumBars 10 3 40 Lookback in bars for the drift that sets trade direction.
AtrPeriod 14 7 30 ATR length used for the stop-loss and take-profit distances.
AtrSlMult 2.0 1.0 4.0 Stop-loss distance as a multiple of ATR.
AtrTpMult 3.0 1.0 6.0 Take-profit distance as a multiple of ATR.
MaxSpreadPoints 80 5 300 Skip new entries when the current spread (in points) is wider than this.
Lots 0.10 0.01 1.0 Fixed lot size for each position.
Magic 8317 0 9,999,999 Magic number used to identify and manage this EA's positions.
variance ratio trend regime EA — MQL5 source code

Recommended Chart Settings

The Variance Ratio Trend Regime strategy was designed with liquid instruments in mind — FX majors (such as EUR/USD or GBP/USD), major indices, or metals like gold — on intraday timeframes between M15 and H1. These timeframes give the rolling return window enough clean data to estimate the variance ratio while still producing a reasonable number of signals.

That said, the strategy is not locked to any single market. It reads whatever symbol and timeframe you attach it to, so you are free to study its behavior across different instruments. Keep in mind that results will vary considerably across market conditions, sessions, and instruments. A regime filter that behaves well on a trending index may behave very differently on a range-bound cross. Always test any configuration on historical data and a demo account before considering it further.

How to Install on MetaTrader 5

What to Consider Before Using This EA

Strengths of this approach. The most interesting feature of this strategy is its honesty about when not to trade. Naive momentum systems tend to bleed capital in sideways markets because they keep firing signals into noise. By requiring a statistically trending regime before any entry, the Variance Ratio Trend Regime strategy tries to sidestep exactly those conditions. The variance ratio is also a horizon-weighted blend of autocorrelations, which historically makes it a more robust trend gauge than a single moving-average slope. Combining the regime gate with a drift direction and a continuation candle adds two independent layers of confirmation, and the ATR-based stops adapt to changing volatility.

Known limitations. No filter is perfect. The variance ratio is a lagging, backward-looking statistic — it describes the recent window, not the next bar, so regimes can flip after the strategy has already committed to a trade. In fast-reversing markets, momentum entries can be caught at the tail end of a move (the classic risk of any trend-follower). The strategy also uses fixed-lot sizing and takes only one position at a time, so it does not scale exposure to account equity or volatility on its own. Overlapping q-period returns, used to estimate variance, are statistically noisy on short windows, and choosing VrWindow or VrLag too small can make the gate unstable.

Where it may underperform. Choppy, low-volatility ranges that never build a persistent trend, news-driven whipsaws, and thin or high-spread conditions are all environments where a momentum-after-confirmation approach can give back gains. The spread filter helps with the last of these, but it cannot eliminate slippage or gaps. Treat every parameter as a hypothesis to be tested, not a setting to trust blindly.

Risk Management Tips

Sound risk management matters more than any single entry rule. As you study this strategy, keep these general principles in mind:

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