2020issue C0649-56
Constructing a correlation-cycle market-state engine
A lookback of price is correlated with a cosine and a negative sine of a chosen period, converted into a constrained phase angle, and then classified as uptrend, downtrend, or cycle mode. This archive article shows how those pieces form one switchable market-state reading that can be rebuilt and checked on an explicit out-of-sample chart.
- A correlation-cycle reading correlates a lookback of price with a cosine and a negative sine of a user-chosen period, and it computes those real and imaginary parts only when both correlation denominators are positive.
- Phase angle is 90 degrees plus the arctangent of the real-to-imaginary ratio when the imaginary part is nonzero, then shifted by minus 180 degrees when the imaginary part is positive, and it is held at the prior value when the angle would otherwise decline by less than 270 degrees.
- Market state is a downtrend when the absolute bar-to-bar angle change is under 9 degrees and the angle is negative, an uptrend when that change is under 9 degrees and the angle is non-negative, and cycle mode otherwise.
- A mode-switching illustration keeps two consecutive bars of the same trend state, then applies channel-breakout rules in trend modes and a limit dip-buy in cycle mode, which students can compare with an explicit out-of-sample chart.
A cycle companion that can switch modes
The historical workflow constructs a cycle companion to a prior-month trend indicator by correlating a lookback of price with a cosine and a negative sine of a user-chosen period.
The selected period is the dominant-cycle estimate. It is both the correlation window and the period of the reference-wave pair.
Editorial reading: TradersWeek treats those pieces as one switchable market-state engine. Rebuild the correlation, the phase angle, and the trend filter separately, then compare the combined mode with an explicit out-of-sample chart before treating it as a forecast.
Assemble the real and imaginary parts
In the EasyLanguage construction, the correlation length defaults to the selected period. Close is the price input unless an input-period-override replaces price with a generated sine of a stated period, so the correlation machinery can be checked on a known waveform.
The real part is the correlation of recent price with the cosine reference-wave. The imaginary part is the correlation with the negative-sine reference-wave of the same period. Real and imaginary parts are computed only when both correlation denominators are positive.
Convert the pair into a phase angle
Spectral analysis, in this construction, means forming those real and imaginary correlation components against the fixed-period trigonometric waves, then converting the pair into a phase-angle.
When the imaginary part is nonzero, the angle is 90 degrees plus the arctangent of the real-to-imaginary ratio. If the imaginary part is positive, that angle is then shifted by minus 180 degrees.
If the new angle would decline by less than 270 degrees, the prior value is held instead. That constraint keeps the phase-angle from decreasing except across a large wrap.
Filter trend from cycle
The trend-filter classifies each bar from the bar-to-bar change in phase-angle relative to a degree threshold.
Market-state is set to downtrend when the absolute bar-to-bar angle change is under 9 degrees and the angle is negative. It is set to uptrend when that change is under 9 degrees and the angle is non-negative. Otherwise the bar is left at cycle mode.
Read a mode-switching illustration
A mode-switching-system illustration treats two consecutive bars of state 1 as an uptrend and two consecutive bars of state minus 1 as a downtrend. It then uses channel breakouts in those trend modes and a limit dip-buy when neither trend is present.
The illustration’s stated rules include a next-day buy stop through the 20-day high in an uptrend, a next-day short stop through the 10-day low in a downtrend when shorts are allowed, a next-day buy limit 5 percent below the current low in cycle mode, a minus 10 percent stop-loss, and exits or covers on trend change or on 10-day channel stops.
Editorial note: those rules show how a persistent market-state reading can choose between templates. They are not a present-day trading recommendation.
Rebuild and compare on a chart
Platform reconstructions apply the same correlation-cycle study to daily charts, including Apple Inc. in TradeStation and Wealth-Lab examples and a one-year SPY chart in thinkorswim.
An Excel reconstruction exposes the 9-degree trend-versus-cycle threshold as a control. It notes that published figures use a 20-bar base cycle early and a 14-bar base cycle later.
Daily SPY close on the 14-bar correlation-cycle chart

The source fixed the correlation length at 14 bars. Price readings are approximate to the nearest dollar except the last close of 270.2, which is printed on the chart.
All readings on this track · 21 readings
- 1982Spectrum-first construction of moving-average trend filters
- 1990Crowd questions that switch cycle regimes
- 1993Antithetic twins to cancel origin-linked forecast bias
- 1994Constructing frequency response from a three-stage filter cascade
- 1994Bench-testing smoothers with cycle phase and power
- 1995Constructing minimum tradable cycles from spectral noise
- 1995Spectral whipsaw limits for a price-crossing average
- 1996Constructing market phase from dominant-cycle components
- 2000Constructing a Hilbert squelch dominant-cycle gate
- 2007When cycle mode fails: regime gates for spectral trades
- 2008Constructing singular-spectrum forecast baselines
- 2008Stacking a midband cycle gate on a short-memory trend filter
- 2011Engineering spectral cycle detection and moving-average harmony
- 2011Evaluating fixed oscillators against a moving dominant cycle
- 2011A construction checklist for a dominant-cycle sinewave
- 2012Assembling a market-mode heatmap from successive band-pass filters
- 2012Adaptive trend detection from dominant-cycle spectra
- 2015Constructing price paths from cycles and support
- 2018Oscillator distribution shape for mean-reversion filters
- 2020Constructing a cosine-correlation cycle and phasor trend filter
- 2020Constructing a correlation-cycle market-state engine