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 Anchored Vwap Compression Breakout is a dual anchored-VWAP squeeze-and-breakout system for MetaTrader 5, built around volume-weighted price analysis and a volatility-scaled breakout trigger. VWAP — short for Volume-Weighted Average Price — is the average price paid for an instrument, weighted by how much volume traded at each price. An anchored VWAP starts that calculation from a specific bar you choose rather than from the beginning of the session, so it tells you the average price paid since a meaningful event. Where most anchored-VWAP methods drop a single anchor and either fade it or ride it, this strategy runs two anchors at the same time and only acts when they agree.
The two anchors are placed automatically. The first, VWAP-Hi, is anchored at the most recent swing high — the highest high in a lookback window — and represents the average price paid by everyone who bought since that top. The second, VWAP-Lo, is anchored at the most recent swing low and represents the average price of everyone who bought since the bottom. When these two averages drift close together, buyers-from-the-top and buyers-from-the-bottom have converged on the same fair value. The market is coiled in a volume-weighted equilibrium — a "squeeze" — and range rarely survives such compression for long.
This is a learning tool for traders who want to study how volume-weighted averages, volatility measurement, and breakout confirmation can be combined into a single rules-based system. It is designed for range-compression conditions that resolve into directional expansion, and it applies distinct long and short logic. Because every calculation is volume-weighted and ATR-scaled, the strategy adapts to different symbols and volatility levels without needing to know a market's point size in advance. It is best suited to intermediate traders comfortable with indicators, backtesting, and disciplined risk management rather than to beginners seeking a hands-off tool.
How It Works
The strategy processes one signal per newly closed bar on the selected timeframe. It maintains rolling buffers of price and tick volume, measures volatility with the Average True Range (ATR) — an indicator that captures the average size of recent bars — and evaluates a strict sequence of conditions before any order is placed.
- Locate the anchors: Within the last
AnchorLookbackclosed bars, the strategy finds the highest high and the lowest low. These two bars become the anchor points for VWAP-Hi and VWAP-Lo respectively. - Build the two anchored VWAPs: From each anchor forward to the current bar, it computes a volume-weighted typical price — (High + Low + Close) ÷ 3, weighted by tick volume. This produces the upper rail (the higher of the two VWAPs) and the lower rail (the lower of the two).
- Check for compression: The gap between the upper and lower rail is compared to ATR. If that gap is smaller than
CompressionAtrFrac× ATR, the market is considered compressed and trading is armed. If the rails are too far apart, no trade is taken. - Require a conviction candle: The freshly closed bar's body must be at least
BodyFracof its full range. This filters out indecisive candles with long wicks and small bodies, demanding a decisive close. - Long signal: While compressed, the strategy signals a long when a bullish bar (close above open) closes clear above the upper rail by at least
BreakoutAtrFrac× ATR, and the prior bar's close was still inside the rail. This aims to catch the first genuine break rather than a mid-move chase. - Short signal: While compressed, it signals a short when a bearish bar closes clear below the lower rail by the same ATR buffer, and the prior bar was still inside the rail.
- Stop-loss logic: Risk is set to
AtrStopMult× ATR. A long places its stop that distance below entry; a short places it that distance above. Because the stop is volatility-based, it widens in fast markets and tightens in quiet ones automatically. - Take-profit logic: The target is placed at
RewardRisk× the ATR risk distance. With the default of 1.80, the strategy seeks a reward that is 1.8 times the amount risked on each trade. - Trade management filters: Only one position per magic number is allowed at a time, and new entries are skipped when the current spread exceeds
MaxSpreadPoints, helping avoid entries during illiquid or high-cost conditions.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| AnchorLookback | 60 | 20 | 200 | Number of bars in which to locate the swing high and swing low that anchor the two VWAPs. |
| CompressionAtrFrac | 0.60 | 0.10 | 2.50 | Maximum gap between the two VWAPs, as a fraction of ATR, for the pair to count as compressed and arm trading. |
| BreakoutAtrFrac | 0.15 | 0.00 | 1.00 | How far beyond the rail (as a fraction of ATR) the bar must close to confirm the break and filter marginal pokes. |
| BodyFrac | 0.50 | 0.20 | 0.90 | Minimum breakout-candle body relative to its full range; demands a conviction close. |
| AtrPeriod | 14 | 5 | 40 | Number of bars used to calculate ATR, the volatility-based distance unit. |
| AtrStopMult | 1.50 | 0.50 | 4.00 | Stop-loss distance as a multiple of ATR beyond the entry price. |
| RewardRisk | 1.80 | 0.50 | 4.00 | Take-profit distance expressed as a multiple of the ATR-based risk. |
| MaxSpreadPoints | 120 | 5 | 400 | Skip new entries when the current spread (in points) is wider than this value. |
| Lots | 0.10 | 0.01 | 1.00 | Order volume in lots for each new position. |
| Magic | 5307 | 0 | 9,999,999 | Unique identifier so the EA manages only its own trades. |

Recommended Chart Settings
The Anchored Vwap Compression Breakout is a single-timeframe strategy: every bar read uses the timeframe selected at backtest or run time, so it runs on whatever chart period you attach it to. Its natural home is a liquid market where tick volume is meaningful and spreads stay tight — a major forex pair, gold (XAUUSD), or a stock index — on the M15 to H1 timeframes. These periods tend to produce enough compression-then-expansion cycles for the logic to evaluate without the noise of very low timeframes.
As with any rules-based system, results will vary considerably across symbols, brokers, and market conditions. A configuration that behaves well on one instrument may perform differently on another, so treat the defaults as a starting point for your own study and testing rather than a finished setting.
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
Every strategy has strengths and limitations, and understanding both is part of using any tool responsibly.
Strengths. The dual-anchor design is conceptually elegant: instead of guessing where equilibrium sits, it lets the two volume-weighted averages converge and signal it directly. Because the compression gate, breakout buffer, and stops are all ATR-scaled, the system adapts to different volatility regimes without manual retuning of point values. The body-fraction and prior-bar-inside conditions are genuine filters that reduce reactions to wicks and marginal pokes, and the spread filter helps avoid costly entries.
Limitations. Breakout systems are prone to false breaks. A market can close clear of a rail, trigger an entry, and then reverse straight back into the range — a "fakeout" — which is one of the most common ways such strategies give back gains. Compression can also persist far longer than expected, and when the break finally comes it may be too abrupt for a clean fill. Because the strategy takes only one position per magic and relies on a fixed reward-to-risk target, it does not trail profits or scale out, so strong trends may not be fully captured. In choppy, low-volatility markets with no clear expansion, signals may be infrequent or whipsaw-prone.
The honest conclusion is that this is a well-structured framework for studying volume-weighted compression and breakout mechanics — not a set-and-forget solution. Forward-testing on a demo account and reviewing how it behaves across varied conditions is essential before drawing any conclusions.
Risk Management Tips
Sound risk management matters more than any single entry rule. Consider these general principles as you study this strategy:
- Risk a small, fixed fraction per trade. A common guideline is to risk no more than 1–2% of account equity on any single position, so that a string of losing trades does not threaten the account.
- Size positions to the stop, not the other way around. Because this EA's stop is ATR-based and varies with volatility, calculate your lot size from the stop distance rather than trading a fixed lot blindly.
- Test on a demo account first. Run the strategy on a demo or a small account across different market conditions before considering any live capital.
- Understand drawdown. Even a well-designed system experiences losing streaks. Know the maximum drawdown you are willing to tolerate and how it affects you psychologically.
- Account for costs. Spreads, commissions, and slippage all erode results, especially on lower timeframes; the spread filter helps, but real-world costs still matter.
- Never over-leverage. Leverage magnifies both gains and losses. Keep exposure modest, and never trade with money you cannot afford to lose.
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: AnchoredVwapCompressionBreakout.ex5 (0 downloads)
- Source Code: AnchoredVwapCompressionBreakout.mq5 (0 downloads)
- Documentation: AnchoredVwapCompressionBreakout.pdf (1 downloads)