Blog / Strategy
Strategy

Yang Zhang Expansion Momentum

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?

Yang Zhang Expansion Momentum is a volatility-regime trend-initiation strategy for MetaTrader 5. It is built around the Yang-Zhang realized volatility estimator — a drift-independent, gap-inclusive way of measuring how energetic a market is — and it trades in the momentum style, aiming to step into young trends at the moment volatility ignites. Rather than reacting to price crossing a level, it reacts to a shift in market character: a quiet market waking up.

The core idea rests on a well-documented market behaviour called volatility clustering — periods of calm tend to be followed by more calm, and bursts of activity tend to cluster together. The strategy watches for the transition from calm to active. It measures current Yang-Zhang volatility (abbreviated "YZ") each bar and compares it to a slow baseline of its own recent history. When YZ makes a fresh expansion above that baseline, the market is treated as igniting. Critically, the strategy only acts on the single bar that crosses — it never chases a regime that is already hot.

This makes Yang Zhang Expansion Momentum a useful learning tool for traders who want to understand realized-volatility estimators and regime-detection logic rather than the classic oscillators most beginner strategies use. It is designed for markets that alternate between compression and expansion, and it is best studied by those already comfortable with the basics of moving averages, ATR-based stops, and how an Expert Advisor (EA) processes completed bars. It is presented here as a strategy analysis, not a shortcut — the goal is to understand why each rule exists.

How It Works

The strategy operates once per completed bar on a single timeframe (the chart's own period). Each new bar, it recalculates volatility, updates its baseline, and checks its rules in a fixed order.

Volatility measurement (the engine):

Entry conditions — the strategy signals a trade only when all of the following align:

Exit conditions — the strategy manages a position with three separate exits:

In plain terms: the strategy waits for a quiet market to wake up in a direction it is already leaning, rides that ignition with a volatility-scaled stop and target, and steps aside the moment the energy fades.

Yang Zhang volatility MT5 EA
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
VolPeriod 20 10 50 Window (in bars) for the Yang-Zhang volatility calculation and the drift measurement. Shorter reacts faster; longer is smoother.
BaselinePeriod 50 20 150 Number of prior YZ values averaged into the slow baseline that volatility must expand above.
ExpansionFactor 1.15 1.0 1.6 Multiplier applied to the baseline to form the ignition threshold. Higher values demand a stronger expansion before arming an entry.
MinDriftZ 0.50 0.0 2.0 Minimum absolute normalized drift (driftZ) required to define a tradable direction. Higher values reject weaker leans.
AtrPeriod 14 7 30 Lookback period for the ATR used to size the stop and target.
AtrStopMult 2.0 1.0 4.0 ATR multiple that sets the distance of the protective stop-loss from entry.
AtrTargetMult 3.0 1.0 6.0 ATR multiple that sets the distance of the take-profit target from entry.
Lots 0.10 0.01 1.0 Fixed trade volume in lots. Should be adjusted to your account size and risk tolerance.
Yang Zhang volatility MT5 EA — MQL5 source code

Recommended Chart Settings

Yang Zhang Expansion Momentum is a single-timeframe strategy — every calculation uses the chart's own period, so it runs on whichever timeframe you attach it to. Because the logic depends on volatility clustering and clean gap behaviour, it is generally most instructive on liquid instruments such as major forex pairs (for example EUR/USD or GBP/USD) on intraday timeframes like H1 or H4, where regime shifts are frequent enough to study but not dominated by microstructure noise.

There is no universally "correct" symbol or timeframe. Volatility behaviour differs across instruments and sessions, and the same parameter set can behave very differently on a fast index CFD versus a slow currency cross. Treat the defaults as a starting point for study, and expect results to vary considerably across different market conditions and periods.

How to Install on MetaTrader 5

What to Consider Before Using This EA

Strengths of this approach. The Yang-Zhang estimator is one of the more statistically robust volatility measures available — it accounts for overnight gaps and stays unbiased even when price is drifting, which many simpler measures do not. By requiring a fresh expansion cross plus a pre-existing directional lean, the strategy filters out two common false-signal sources: chasing an already-extended move, and entering an expansion that has no direction. The independent regime exit is a thoughtful touch, since it can release a position when the underlying volatility condition disappears rather than waiting passively for a stop.

Known limitations. Regime-ignition systems are, by nature, reactive to a transition that may not persist. Volatility can expand and then immediately revert, producing a "false ignition" that stops the trade out. In choppy or range-bound markets, the strategy may take entries that reverse quickly, and the asymmetric target (wider than the stop) means winning trades must run to justify the losers. Parameters like ExpansionFactor and MinDriftZ are sensitive — set them too loose and noise slips through; too tight and genuine trends are missed. There is also a structural constraint: only one position is held at a time, so the strategy cannot scale into a strong move.

Where it may underperform. Persistently low-volatility, mean-reverting conditions rarely produce clean ignition crosses, and violently gapping or news-driven markets can trigger entries just before sharp reversals. As with any single-timeframe momentum system, whipsaw environments are its hardest test. Study its behaviour across several market regimes before drawing any conclusions.

Risk Management Tips

Sound risk management matters far more than any single strategy's rules. Consider the following 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