OPEN-SOURCE SCRIPT

Hurst Cycle Alignment Board

341
█ OVERVIEW

The Hurst Cycle Alignment Board fits three fixed cycles from J.M. Hurst's nominal model, the 40-week, 20-week and 10-week cycles, to the chart's price series and shows them as three direction-colored waveforms in a separate pane, shading the background when all three move the same way. It is a regime and timing view built on the premise that price contains a small set of harmonically related cycles whose turning points tend to cluster when the cycles align.


█ HISTORY / BACKGROUND

The cycle lengths come from the nominal model described by J.M. Hurst in "The Profit Magic of Stock Transaction Timing" (1970) and his later cyclic work. Hurst proposed that price action across markets is dominated by a recurring set of cycles related to one another by small integer ratios, most often 2 to 1. The three lengths used here are consecutive harmonics of that ladder: the 40-week cycle (average wavelength about 38.97 weeks) divides into two 20-week cycles (about 19.48 weeks), which divide into two 10-week cycles, the latter also called the 80-day cycle (about 9.74 weeks, near 68.2 calendar days).

Three of Hurst's stated principles motivate viewing them together rather than singly: harmonicity (cycles relate by simple ratios), synchronicity (cycles tend to trough together) and proportionality (longer cycles carry larger amplitude). The fitting method applied to those fixed lengths, a single-frequency least-squares projection, is a standard signal-processing technique. The script does not search for or discover cycle lengths; the three periods are fixed inputs.


█ HOW IT WORKS

For each of the three cycles the script performs the same steps, all on the chart's own series:

Period in bars. Each length is entered in calendar weeks and converted to a bar count at runtime. On a daily chart the count is weeks multiplied by the Market days per week setting; on a weekly chart it is the number of weeks; on a monthly chart it is weeks divided by 4.345. Results are rounded and floored at a small minimum.
Detrend. The script takes the natural log of the source and subtracts a simple moving average of that log series. The averaging length is the long-cycle bar count multiplied by the Detrend length factor, removing slow trend before the fit.
Single-frequency fit. With angular frequency w = 2*pi / period and t = bar_index, the script computes two rolling correlations over a trailing window of length L (the cycle period multiplied by the Fit window factor): a = 2/L * sum(detrended * cos(w*t)) and b = 2/L * sum(detrended * sin(w*t)). These are the least-squares coefficients of one sinusoid at that frequency, equivalent to a single bin of a discrete Fourier transform (a Goertzel-style evaluation). The fitted cycle value at any bar is a*cos(w*t) + b*sin(w*t), and its amplitude is A = sqrt(a^2 + b^2).
Significance. Each cycle's significance is the share of windowed variance it explains: 0.5*(a^2 + b^2) divided by the variance of the detrended series over the same window, clamped to the range 0 to 1.
Normalization and stacking. Each fitted cycle is divided by its own amplitude to a unit-amplitude waveform and placed in its own horizontal band, separated by the Band spacing value, so the three appear stacked in one pane.
Direction and alignment. A cycle is treated as rising when its current fitted value is greater than or equal to the previous bar's value. When all three rise the background shades in the rising color; when all three fall it shades in the falling color; otherwise it is unshaded. The first bar of each all-rising or all-falling stretch is marked with a triangle on the main price chart.

A composite waveform, labeled "push", is the significance-weighted (or equal-weighted) average of the three normalized cycles and can optionally be drawn in a fourth band. A forward projection extends each cycle, and the composite, to the right of the last bar by evaluating the same a*cos(w*t) + b*sin(w*t) expression at future bar indices using the last bar's coefficients.


█ HOW TO USE

Recommended timeframe: daily, weekly or monthly. The cycle lengths are multi-week, so they are meaningful only on these resolutions; on intraday the output is suppressed and an on-chart note is shown. The daily chart is the primary design target, because the periods, expressed in trading days through the Market days per week setting, map to one bar per day.

Reading the output:

• The three waveforms, top to bottom, are the 40-week, 20-week and 10-week cycles, each colored by direction.
• Background shading marks stretches where all three cycles move the same way. Unshaded stretches are mixed.
• Triangles on the price chart mark the bar where a fully aligned stretch begins, up-triangles for all rising and down-triangles for all falling.
• The table at the top right lists each cycle's period in bars and weeks, its significance value and its current direction, plus a today row showing the overall state: ALL UP, ALL DOWN or MIXED.
• The forward projection to the right of the last bar is the deterministic continuation of each fitted cycle. It is a model output, not a price target.

Set Market days per week to match the instrument: 5 for stocks, indices, futures and forex; 7 for markets that trade every day, such as crypto, so a given calendar cycle maps to the correct number of daily bars.


█ SETTINGS

Cycles (calendar weeks)
Long cycle (40-week). Long cycle length in calendar weeks. Default 38.97.
Mid cycle (20-week). Mid cycle length in calendar weeks. Default 19.48.
Short cycle (10-week). Short cycle length in calendar weeks. Default 9.74.

Instrument / timeframe
Market days per week. Trading days per week, used to convert weeks to bars on daily charts. Default 5.

Fit
Source. The series the cycles are fitted to. Default close.
Fit window (x period). Length of the trailing least-squares window, as a multiple of each cycle's period. Default 3.0.
Detrend length (x long period). Length of the trend-removal moving average, as a multiple of the long-cycle bar count. Must exceed 1. Default 1.5.

Display
Rising. Color for a rising cycle. Default teal.
Falling. Color for a falling cycle. Default red.
Band spacing. Vertical distance between the stacked cycle bands. Default 2.4.
Project cycles forward. Draws the forward projection. Default on.
Projection length (bars). Number of bars projected forward, limited to 400. Default 250.
Projection step. Draws one projected segment every N bars to limit object count. Default 3.
Show composite (push) band. Draws the composite waveform in a fourth band. Default off.
Weight composite by fit significance. When on, the composite weights each cycle by its significance; when off, the three are equally weighted. Default on.


█ WHAT MAKES IT ORIGINAL

The script is a self-contained implementation that combines three elements in one tool. First, it fixes the three cycle lengths to Hurst's nominal harmonics rather than searching for dominant periods. Second, it determines each cycle's phase and amplitude automatically by a single-frequency least-squares fit (a one-bin DFT) to detrended log price, recomputed every bar, instead of anchoring cycles to a manually chosen pivot or to a future line of demarcation. Third, it reduces the three cycles to a single regime read by shading only when all three agree in direction and by marking the onset of each aligned stretch on the price chart.

Because the chosen lengths are true 2-to-1 harmonics, the all-aligned condition corresponds to the synchronized turning that Hurst's model expects, rather than a coincidental phase overlap of unrelated periods. The lengths are entered in calendar weeks and converted to bars from the chart timeframe and a trading-days-per-week setting, so the same nominal cycles apply consistently across instruments and across daily, weekly and monthly resolutions.


█ NOTES / LIMITATIONS

Repainting. The fit is recomputed on every bar over a trailing window, so both the historical cycle estimates and the forward projection update as new bars arrive, and a cycle's direction can change on the developing bar. Treat the most recent bars and the projection as provisional until the bar closes. The script uses no request.security calls and no lookahead.
Timeframe. Only daily, weekly and monthly are supported. On intraday resolutions all output is suppressed and an on-chart note is shown.
History required. Each cycle needs roughly the detrend length plus the fit window of prior bars before it returns a value. At default settings on a daily chart this is on the order of 900 bars for the long cycle, so on symbols with little history the long cycle may not render until enough bars exist.
Forward projection bounds. The projection extends a fixed number of bars (default 250, capped at 400). Pine does not draw beyond about 500 bars into the future, so the projection cannot be extended arbitrarily far.
Object and compute limits. The projection is drawn with line objects, capped at 500 and internally held under 490; the Projection step setting reduces the count by drawing one segment every N bars. The maximum historical reference is set to 1800 bars.
Instrument setting. There is no symbol-class restriction, but Market days per week must match the instrument (5 for conventional markets, 7 for markets trading every day); otherwise the calendar-to-bar conversion on daily charts will be off.
Amplitude display. Each cycle is normalized to unit amplitude for the stacked display, so band height does not convey relative cycle strength; the significance column in the table carries that information.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。