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 Harmonic Octave Reversion strategy is a mean-reversion system built around a Murray-Math-style octave grid, a harmonic-subdivision technique that traces its roots to the work of W.D. Gann and later T.H. Murray. The core idea is that a defined price range tends to respect harmonic subdivisions of itself. This expert advisor (EA) takes the recent trading "frame" — the highest high and lowest low of a lookback window — and slices it into eight equal levels, or "octaves," where 0/8 is the frame low, 4/8 is the mid axis (fair value), and 8/8 is the frame high.
Mean reversion is a trading style that assumes price stretched to an extreme is more likely to snap back toward an average than to continue in a straight line. The Harmonic Octave Reversion strategy applies this idea specifically to failed probes of the frame extremes. When a candle pierces the 0/8 line but closes back inside the frame, the strategy interprets this as a failed downside breakout — a signal that the auction at that extreme is exhausted and price may be pulled back toward the 4/8 mid axis. The mirror logic applies to failed probes of the 8/8 line on the upside.
As a learning tool, this strategy is well suited to traders who want to study range-bound, balanced market behavior and how harmonic price levels can be defined objectively. It is best understood as a case study in mean-reversion mechanics — combining level detection, a trend filter, and disciplined reward-to-risk gating — rather than as a shortcut to any particular outcome. It suits intermediate learners comfortable with concepts like ATR (Average True Range) and EMA (Exponential Moving Average).
How It Works
The strategy evaluates conditions once per closed bar and works exclusively on a single timeframe. Here is the logic in plain English:
- Building the octave frame: The strategy scans the last
FramePeriodbars before the just-closed bar to find the highest high (8/8 line) and lowest low (0/8 line). The midpoint between them becomes the 4/8 mid axis, which acts as the "fair value" target. - Frame width filter: The frame must span at least
MinFrameAtrmultiples of ATR. This ensures the octave grid represents a meaningful range and that the mid-axis target sits a genuine distance away, so the reward-to-risk geometry is real rather than noise. - Trend slope gate: The strategy measures the displacement of an EMA over the last few bars, expressed in ATR units. This gauges whether a strong trend is running. Fades against a strong opposing trend — the classic way a reversion system bleeds — are blocked.
- Long entry signal: The strategy signals a long when the just-closed bar dipped its low below the frame low (0/8) but closed back above it, while still sitting below the 4/8 mid axis, and the EMA slope is not in a strong downtrend. This is read as a failed downside probe.
- Short entry signal: The strategy signals a short when the just-closed bar poked its high above the frame high (8/8) but closed back below it, while still sitting above the 4/8 mid axis, and the EMA slope is not in a strong uptrend. This is a failed upside probe.
- Take-profit logic: For both directions, the take-profit target is the 4/8 mid axis — the fair-value pull-back level.
- Stop-loss logic: For longs, the stop sits
AtrStopMultATRs below the frame low; for shorts, the same distance above the frame high. This places the stop just beyond the level that was defended. - Reward-to-risk check: Before any order is sent, the strategy compares the distance to target versus the distance to stop. If the reward does not meet the
MinRewardRiskmultiple of the risk, the trade is skipped. - Breakeven lock: An optional feature ratchets the stop up to the entry price once price has travelled a configurable fraction (
BreakevenPct) of the way to the target, which may help cap give-back on a trade that has moved in favor. - One position at a time: The EA holds only a single open position per magic number, keeping exposure controlled.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| FramePeriod | 64 | 24 | 200 | Number of prior bars used to build the octave frame (highest high / lowest low). |
| MinFrameAtr | 3.0 | 1.0 | 8.0 | The frame must span at least this many ATRs to be considered tradeable. |
| SlopeEmaPeriod | 50 | 10 | 150 | Period of the EMA used to gauge the prevailing trend for the slope gate. |
| FlatSlopeAtr | 1.0 | 0.2 | 3.0 | Rejects a fade if the opposing EMA slope (measured in ATR units) exceeds this. |
| AtrPeriod | 14 | 5 | 30 | Lookback period for the Average True Range volatility measure. |
| AtrStopMult | 1.2 | 0.5 | 3.0 | Stop sits this many ATRs beyond the pierced frame extreme. |
| MinRewardRisk | 1.2 | 0.8 | 3.0 | Minimum reward-to-risk ratio (target vs stop) required to take a trade. |
| BreakevenPct | 0.5 | 0.0 | 1.0 | Locks the stop to breakeven once price travels this fraction toward target (0 = off). |
| Lots | 0.10 | 0.01 | 1.0 | Trade volume in lots per position. |

Recommended Chart Settings
The Harmonic Octave Reversion strategy is designed to operate on a single timeframe and reads all of its data from the chart's primary symbol and period. Because it is a mean-reversion approach that depends on a well-defined trading frame, it tends to be studied most naturally on liquid instruments that spend meaningful time in balanced, range-bound conditions — major forex pairs are a common starting point for this kind of analysis.
Intraday and swing timeframes such as H1 or H4 offer a reasonable balance between having enough bars to build a stable frame and reacting to fresh probes of the extremes. That said, the octave grid and every filter are volatility-relative through ATR, so the strategy can be examined across a range of symbols and timeframes. Results will vary considerably across different market conditions, and any timeframe or symbol should be tested thoroughly before it is relied upon.
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 trading approach has strengths and trade-offs, and the Harmonic Octave Reversion strategy is no exception.
Strengths of this approach:
- The octave frame gives an objective, rule-based way to locate support and resistance, removing much of the subjectivity of manual level drawing.
- The failed-probe requirement (pierce then close back inside) filters out clean breakouts, focusing only on rejections at the extremes.
- Multiple robustness gates — frame width, trend slope, and a minimum reward-to-risk — are layered to avoid the weakest setups.
- The breakeven lock and ATR-based stop reflect a disciplined, structural approach to defining risk on each trade.
Known limitations of mean reversion:
- Mean-reversion systems are inherently vulnerable to strong, persistent trends. When a market breaks out and keeps running, fading the extreme can lead to repeated losses. The slope gate is designed to reduce this, but no filter is perfect.
- The strategy trades relatively selectively, so signal frequency may be low. Periods without qualifying setups are normal and expected.
- Because the frame is rebuilt from recent bars, its levels shift over time; the same visual "level" you might draw by hand may not match the EA's computed frame.
- During volatility regime changes, ATR-based sizing of the stop and frame-width filter may cause the strategy to skip trades or place wider stops than anticipated.
This EA should be viewed as a structured framework for studying harmonic mean reversion, not as a finished solution. Thorough forward testing and an understanding of why each filter exists are essential before considering it in any live context.
Risk Management Tips
Sound risk management matters more than any single entry signal. Consider these general principles as you study this or any strategy:
- Position sizing: Keep your trade size proportional to your account. A widely referenced guideline is to risk no more than 1–2% of account equity per trade, so that a string of losses does not do lasting damage.
- Use a demo account first: Test the strategy on a demo or paper-trading account until you understand how it behaves across different market conditions.
- Understand drawdown: Every strategy experiences losing streaks. Study the historical drawdown behavior so you are mentally and financially prepared for the inevitable down periods.
- Respect the stop: The ATR-based stop is central to this strategy's design. Disabling or overriding stops removes the primary control on downside risk.
- Diversify your study: Avoid concentrating all of your attention — or capital — on a single instrument or a single approach.
- Keep records: Maintaining a trading journal helps you learn what conditions favor or hurt a mean-reversion system like this one.
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: HarmonicOctaveReversion.ex5 (7 downloads)
- Source Code: HarmonicOctaveReversion.mq5 (6 downloads)
- Documentation: HarmonicOctaveReversion.pdf (13 downloads)