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?
Correlation Cycle Phase Shift is a dominant-cycle timing strategy that fits a single sine wave to recent price and trades the turning points of that fitted wave — a swing-timing approach built around a least-squares sinusoidal regression rather than a conventional moving average or oscillator. Where many "cycle" tools extract a rhythm using recursive smoothing filters, this expert advisor (EA) takes a more direct statistical route: over one assumed cycle length it projects de-meaned closing prices onto two orthogonal reference waves — a cosine and a sine — and measures how closely price actually tracks that ideal cycle.
The key idea is a "cycle strength" reading, labelled M, which ranges from 0 to 1. A value near 1 means a clean single cycle explains price movement very well; a value near 0 means price is behaving like noise or a straight trend, where fitting a sine wave is meaningless. The strategy only acts on the wave's turns when M is high enough, so it is designed for liquid, range-prone or swinging markets — think FX majors and metals such as EURUSD, USDJPY, or XAUUSD on intraday timeframes — rather than for strongly trending conditions.
As a learning tool, Correlation Cycle Phase Shift is well suited to traders who want to understand how signal-processing concepts (phase, amplitude, correlation) can be applied to price data, and how a regime filter can be used to suppress trades in unfavourable conditions. It is a study in disciplined, conditional entries — not a shortcut to results. Treat it as a way to explore cycle analysis, not as a finished system.
How It Works
The strategy works entirely on closed primary-timeframe bars and evaluates once per new bar. On each new bar it re-fits the cycle and looks for a change in the fitted wave's direction (its slope), gated by the cycle-strength filter.
- Fitting the cycle: Over the last
CyclePeriodclosed bars, the strategy builds cosine and sine reference waves for one full cycle and correlates them with de-meaned closes. This produces aRealcomponent (correlation with cosine) and anImagcomponent (correlation with sine). - Measuring strength: Cycle strength
M = sqrt(Real² + Imag²), capped at 1. High M means a genuine, tradeable cycle; low M means the sinusoid fit is not meaningful. - Reading the turn: Because the cosine/sine/constant basis is orthogonal over a full period, the least-squares fit reduces to a simple amplitude calculation, and the slope of the fitted wave at the newest bar can be computed directly. A positive slope means the fitted cycle is rising (price near a trough, turning up); a negative slope means it is falling (near a peak, rolling over).
- Long signal: The strategy signals a long when the fitted slope crosses up through zero (a cycle trough) and M is at or above
CycleStrengthMin. - Short signal: The strategy signals a short when the fitted slope crosses down through zero (a cycle peak) and M is at or above
CycleStrengthMin. - Position flipping: A fresh opposing signal closes any existing position and opens one in the new direction. A same-direction signal while already positioned is ignored, so the EA does not stack trades.
- Spread filter: New entries are skipped when the current spread (in points) is wider than
MaxSpreadPoints, helping avoid entries during poor-liquidity moments. - Stop-loss logic: The stop is placed a distance of
AtrStopMult × ATRaway from the entry, where ATR (Average True Range) measures recent volatility. This adapts the stop to how much the market is currently moving. - Take-profit logic: The take-profit distance is set as a reward-to-risk multiple of the stop,
TpRewardRisk × stopDist. With the defaults, this targets 1.5 units of reward for every 1 unit of risk.
In short, the strategy signals only at cycle turns that occur while a measurable cycle is present, then manages the trade with a volatility-based stop and a fixed reward-to-risk target.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| CyclePeriod | 20 | 8 | 60 | Assumed dominant cycle length and the correlation/fit window, in bars. Larger values track slower swings; smaller values track faster ones. |
| CycleStrengthMin | 0.55 | 0.20 | 0.90 | Minimum cycle strength M required to trade a turn. Higher values demand a cleaner, more convincing cycle before entering. |
| AtrPeriod | 14 | 5 | 40 | Lookback period for the ATR volatility measure used to size the stop. |
| AtrStopMult | 2.0 | 0.5 | 5.0 | Stop-loss distance as a multiple of ATR beyond the entry price. |
| TpRewardRisk | 1.5 | 0.5 | 4.0 | Take-profit distance expressed as a reward-to-risk multiple of the ATR stop. |
| MaxSpreadPoints | 80 | 5 | 300 | Skip new entries when the current spread (in points) is wider than this value. |
| Lots | 0.10 | 0.01 | 1.0 | Order volume (position size) in lots. |
| Magic | 8123 | 0 | 9,999,999 | Magic number used to identify and manage this EA's own positions. |

Recommended Chart Settings
Correlation Cycle Phase Shift was designed with liquid, range-prone FX majors and metals in mind — for example EURUSD, USDJPY, or XAUUSD — on intraday timeframes around M15 to H1, where mean-reverting swing cycles are more common. These conditions give a fitted sinusoid the best chance of describing price behaviour.
The EA runs on whatever symbol and timeframe the chart is set to at run time, so you are free to test it elsewhere. Keep in mind that cycle behaviour, volatility, and spread characteristics differ widely between instruments and sessions, so results will vary across different market conditions. Always test any configuration on historical data and a demo account before drawing conclusions.
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 involves trade-offs, and understanding them is part of using any tool responsibly.
Strengths of this approach:
- The cycle-strength filter (M) is an explicit regime gate. By requiring a clean cycle before acting, the strategy attempts to sit out the whipsaw of trending or random conditions where cycle timing tends to fail.
- Least-squares fitting is a well-defined statistical method, so the slope and strength readings are transparent and repeatable rather than the product of hidden smoothing.
- Volatility-based (ATR) stops and a fixed reward-to-risk target give the trade management a consistent, rules-based structure with symmetric long and short logic.
Known limitations:
- Cycle-timing methods assume the market has a stable, repeating rhythm. Real markets shift between trending and cyclic regimes, and cycles can lengthen, shorten, or vanish. During strong trends, taking counter-cycle turns can lead to a string of losses even when the strength filter is applied.
- The strategy commits to one cycle length (
CyclePeriod). If the true dominant cycle drifts away from that length, the fit degrades and signals may come late or early. - A high
CycleStrengthMinreduces trade frequency, which can mean long quiet periods; a low value lets through weaker setups. Finding a balance is a matter of testing, not a fixed rule. - Like all least-squares fits, the model can be sensitive to sudden shocks and gaps that distort the correlation over the window.
The strategy may underperform in persistent one-directional trends, in extremely low-volatility drift, or during news-driven spikes. Treat it as one lens on the market rather than a complete answer.
Risk Management Tips
Sound risk management matters more than any single entry rule. Consider these general principles:
- Position sizing: Size trades so a single loss is a small fraction of your account. Many educational sources suggest risking no more than 1–2% of account equity per trade.
- Respect the stop: The ATR-based stop exists to define your risk before you enter. Avoid widening or removing it mid-trade.
- Use a demo account first: Test the EA and any parameter changes on a demo account across varied market conditions before considering real capital.
- Understand drawdown: Even a well-designed rules-based strategy will have losing streaks. Know the maximum drawdown you are willing to tolerate and plan for it in advance.
- Account for costs: Spread, commission, and slippage all reduce net outcomes. The
MaxSpreadPointsfilter helps, but real-world execution can still differ from a backtest. - Diversify and avoid over-leverage: Do not concentrate risk in a single instrument or over-leverage your account chasing more trades.
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: CorrelationCyclePhaseShift.ex5 (6 downloads)
- Source Code: CorrelationCyclePhaseShift.mq5 (6 downloads)
- Documentation: CorrelationCyclePhaseShift.pdf (7 downloads)