Millard Channels and Cycles

950
█ OVERVIEW

Millard Channels and Cycles reconstructs the channel and cycle method that Brian J. Millard set out in Channels and Cycles: A Tribute to J. M. Hurst (1999). It draws on two panes.

On the price chart it plots up to three nested channels of constant depth, each built around a centred moving average:
• the exact section of each channel, which ends half a span before the last bar;
• an estimate of each channel across that missing half span and a short distance beyond it;
• buy, short and exit markers that follow the book's entry and exit rules;
• an optional status table.

In its own pane it plots:
• a cycle highlighter (one centred average minus another) or an average difference;
• an estimate of the highlighter across its own missing half span;
• confirmed cycle peaks and troughs;
• a box that marks where and when the next cycle turn is expected.

Thesis: if price is a sum of cycles plus random movement, a constant-depth band around a centred average shows both the trend at that average's time scale and the combined range of every faster cycle.


█ HISTORY / BACKGROUND

J. M. Hurst published The Profit Magic of Stock Transaction Timing in 1970. His work rested on cycles that add together, envelopes drawn around price, and the observation that the best buying points come when several cycles bottom together. Brian J. Millard, a British university scientist who turned to market analysis after reading Hurst, developed those ideas in his own books. This script follows his 1999 book, chapters 4 to 10.

Millard's conceptual basis, as the book states it:
• A trend is half of a cycle, and cycles add. A rising long cycle makes short rises larger than short falls; a falling one does the reverse.
• A simple moving average removes a cycle whose wavelength equals its span. It passes longer cycles with reduced size, and can shift shorter ones by half a wavelength. A centred average of the right span therefore traces the trend at that time scale without lag.
• A channel whose upper and lower bounds stay a constant vertical distance apart, placed around that centred average, contains every cycle shorter than the span plus the random movement. Its depth measures their combined size. Channels of increasing span nest inside one another.
• Subtracting one centred average from another isolates a band of cycle lengths. Millard calls this the cycle highlighter.
• A centred average of span N is only known up to (N − 1) / 2 bars before the last bar. The channel's position across that gap must be estimated. The book treats that estimate, and the detection of channel turns inside the gap, as the central problem of the method.

The book gives a manual procedure for the gap: a smooth continuation, bends when recent peaks or troughs break a boundary, reversals that mirror the channel about the turning point, and inner channels that turn back when they meet the next outer channel. It also gives a computer procedure: a least-squares quadratic fitted to the last few calculated points and adjusted to pass through the end points.

The book also mentions the author's own probability-based algorithms for the gap and for turning-point timing, along with a predictability score. Those algorithms were never published and are not reproduced here. The drop-point estimator in this script is a separate construction, explained below.


█ HOW IT WORKS

1. Spans and centred averages. Every span is forced to an odd number, so the average can be centred. With Smoothed averages off, each channel uses a simple average of span n, centred h = (n − 1) / 2 bars back. With it on, a second simple average is applied to the first. Its span m is (n + 1) / 2 rounded down to an odd number, and the shift becomes (n − 1) / 2 + (m − 1) / 2. The trailing average calculated on the current bar is the centred value for the bar h bars earlier.

2. Constant depth. For each channel, the script takes the absolute distance between the source and the centred average at every calculated point. The half-depth is the nearest-rank percentile of those distances over the last Depth lookback points, at 100 minus Points outside boundaries %. The upper and lower bands are the centred average plus and minus that half-depth. The depth is in price units and updates as new points are calculated.

3. Gap estimate, curve fit. A least-squares quadratic is fitted to the last F calculated centred values. F is the share Curve-fit window of the gap, plus one, with a minimum of 5. A linear correction makes the curve pass exactly through the first and last fitted points. The adjusted curve is then evaluated across the gap and beyond the last bar.

4. Gap estimate, Millard procedure. The script finds the confirmed peaks and troughs of the source inside the gap. A peak is a value above both neighbours; a trough is below both. A peak above the upper band or a trough below the lower band counts as a break when it exceeds Penetration tolerance times the half-depth.
• Breaks on one side only: the script applies the smallest bend that puts every breaking point on its band. The bend grows with the square of the distance into the gap up to the last bar and continues in a straight line after it. Breaks in the first quarter of the gap are accepted rather than forcing a sharp kink. The bend is capped at four half-depths. It is kept if no break remains and the channel's direction at the last bar does not flip.
• Otherwise, with Symmetry reversal on: the channel is reversed. The turn sits at the first breaking point when both sides break. When one side breaks, it sits at the lowest source value in the gap (for an upper break) or the highest (for a lower break). After the turn, the path mirrors the path before it, drawing on exact centred values where the mirror reaches back past the gap. Any remaining one-sided break is then removed with a bend that starts at the turn.
• With Symmetry reversal off: only the bend is applied.

5. Gap estimate, drop-point. The trailing averages are recalculated as if every future value equalled the current source. This uses an exact recurrence on the known values that will drop out of each average window, including the second stage of a smoothed average. No curve is fitted. Under a random-walk assumption, this is the expected path of the centred average across the gap. It applies Millard's observation that an average's next move depends on the value being dropped as well as the value being added.

6. Projection and nesting. Each path continues Projection beyond last bar bars past the last bar. Following the book's outermost-first rule:
• the middle channel's projection is mirrored at the first bar where its band crosses the outer band by more than the tolerance;
• the inner channel's projection is checked the same way against the middle channel, or against the outer channel when the middle one is off;
• up to three reflections are applied.
This rule acts only on the section beyond the last bar.

7. Cycle highlighter. The long average is a simple average of span N (Span). The short span is (N + 1) / 2 rounded up to an odd number; for N = 53 it is 27. The short average is either simple, or triangular (a simple average of a simple average, each of span (short span + 1) / 2). The centred highlighter is the short average centred minus the long average centred. In Average difference mode, the value is the source minus the centred long average. The gap estimate uses the curve fit, or the drop-point recurrence applied to both averages when the drop-point method is selected.

8. Turning points and prediction box. Peaks and troughs of the highlighter are confirmed with a pivot test of Turn confirmation bars on each side; at 0 this is span / 8 rounded, minimum 2. The list of turns is forced to alternate: of two consecutive peaks, the higher is kept, and of two troughs, the lower.

Over the last Half-waves used intervals, the script measures the half-wave lengths (bars between consecutive turns) and the swings (value change between them). It records the minimum, maximum, mean and coefficient of variation of each. The measured wavelength is twice the mean half-wave. A cycle counts as regular when the half-wave CV and the swing CV are both at or below their thresholds.

The box follows the book's chapter 4 rule. Horizontally it spans from the last turn plus the shortest half-wave to the last turn plus the longest. After a peak it spans from the last peak minus the largest swing to the last peak minus the smallest swing; after a trough it mirrors this.

9. Signals. These are computed on each bar from the estimates available at that bar. Position is (source minus lower band) / (upper band minus lower band) of the inner channel at the last bar.

A buy setup requires all of the following:
• the inner channel rising at the last bar;
• the middle channel rising, when enabled;
• the outer channel rising, when Require outer channel in trade direction is on;
• the Cycle filter passing;
• a trough just formed: the prior source value below the one before it, and the current value above the prior value;
• the prior value's position between minus half the tolerance and Boundary zone;
• the current source not beyond a band by more than the tolerance.

An open long exits on the first later bar where any of these occurs:
• the source closes below the lower band by more than the tolerance;
• the position is at or above 1 minus Boundary zone and the source falls;
• the middle channel, when enabled, turns down.

Short setups and exits mirror these rules. Only one position is tracked at a time.

10. Scorecard. At each bar, the estimate of the centred value at that bar is stored. It is scored h bars later, when the true centred value is known. For a channel the script compares five estimators: the Millard procedure, the curve fit alone, the drop-point recurrence, a least-squares line through the same points, and the last true point held flat. For the highlighter it compares the curve fit, the drop-point recurrence and the last true point. For each estimator it reports:
• the mean absolute error, in half-depths for channels and in the 95th percentile of the highlighter's absolute value over 500 bars for the highlighter;
• the share of bars on which the estimated change across the gap had the correct sign;
• the share on which the estimated slope at the bar had the correct sign;
• the error relative to the drop-point estimator.


█ HOW TO USE

Timeframe. The logic contains no timeframe-specific code; every length is counted in bars. The defaults (channels of 41, 101 and 201 bars, highlighter of 53) reproduce the spans in the book's daily-chart examples, so the script is set up for daily charts. On weekly charts the book uses spans of 41 and 53 weeks for longer-term work and then checks timing on daily data.

Price chart.
• Solid lines: the exact centred channels. Inner is blue with a faint centre line, middle orange, outer purple and thicker. Their right ends sit half a span before the last bar.
• Dashed lines: the estimated bands across the gap and the projection. They are redrawn on every bar. A faint dotted line marks the inner channel's estimated centre.
• Grey dotted line (optional): the drop-point estimate of the inner centre.
• Triangles: a green one below a bar is a buy setup; a red one above a bar is a short setup.
• Cross: the exit for whichever position was open.

Indicator pane.
• Blue line: the centred highlighter.
• Dashed blue line: its estimate across the gap and beyond.
• Grey dotted line (optional): its drop-point estimate, shown when the gap method is not drop-point.
• Red and green dots: confirmed peaks and troughs.
• Orange box: the prediction box for the next turn.
• Grey horizontal line: zero.

Reading the channels the way the book describes:
• The outer channel is the long-term trend, the middle channel the medium-term trend and the inner channel the short-term trend.
• The book buys only when the middle and inner channels are rising. It treats a rising outer channel as lower risk.
• It enters after a trough forms on the lower boundary of the rising inner channel, never while price is still falling, mid-channel, or near the upper boundary.
• It exits at the first close through the lower boundary.
• It treats a down close near the upper boundary, or a turn in the middle channel, as reasons to leave.
• When the status table shows "(adjusting)", the latest value lies outside a band and the estimate is being redrawn bar by bar. The book advises no action in that state.

Reading the highlighter:
• Use a cycle only while the table reports it as regular. When the measured wavelength is far from the span, the table adds "(off span)"; setting the span near the measured wavelength isolates that cycle more cleanly.
• A highlighter turning up as the inner channel reaches its lower boundary is the agreement the book looks for. The Cycle filter input turns that agreement into a requirement for setups.
• A next-turn window with negative values means part of the expected window lies inside the gap, where a turn may already have happened without being visible yet.

Status table (off by default):
• Row 1: the direction of each channel at the last bar, the position of price inside the inner channel, and the adjusting flag.
• Rows 2 and 3: the highlighter's estimated direction, the measured wavelength, the half-wave range and CV, the swing CV, the regularity status, the last turn, the next-turn window in bars from the last bar, and the cycle filter setting.
• Lower rows: the scorecard for the selected channel or the highlighter, then the gap method and, for the Millard method, whether the inner gap was left as fitted, bent or reversed.
Use the scorecard to compare the gap estimators on the symbol and timeframe in front of you before relying on any of them.


█ SETTINGS

Channels
• Source (close): the series the channels and highlighter use.
• Inner span (41): span of the inner channel average.
• Middle (on, 101): enables the middle channel and sets its span.
• Outer (on, 201): enables the outer channel and sets its span.
• Smoothed averages (off): applies the second averaging stage described in step 1.
• Points outside boundaries % (3.5): share of calculated points left outside the bands.
• Depth lookback, calculated points (750): number of points used for the depth percentile.

Gap estimate
• Method (Millard: curve fit + bending): the gap estimator for channels and highlighter. Choices: Millard: curve fit + bending, Curve fit only, Drop-point (random walk).
• Curve-fit window, share of gap (0.4): sets the number of fitted points.
• Penetration tolerance, share of half-depth (0.15): how far a peak or trough may pass a band before it counts as a break. Also used by the signal and exit tests.
• Symmetry reversal (on): allows reversals as described in step 4.
• Projection beyond last bar (20): length of the projection.
• Bars with per-bar estimates (1500): number of recent bars on which signals, the cycle filter and the scorecard are calculated.

Cycle highlighter
• Span (wavelength to isolate) (53): long span of the highlighter.
• Calculation (Cycle highlighter): Cycle highlighter or Average difference.
• Short average (Weighted): Weighted (triangular) or Simple.
• Turn confirmation bars (0): bars on each side for the pivot test; 0 uses span / 8.
• Half-waves used (6): number of recent intervals used for the statistics and the box.
• Regular if half-wave CV below (0.25) and and swing CV below (0.5): regularity thresholds.
• Prediction box (on): shows the box.

Signals
• Buy setups (on) and Short setups (off): which sides are tracked and marked.
• Exits (on): shows the exit markers. Positions are closed by the exit rules either way.
• Buy colour, Short colour, Exit colour: marker colours (green, red, yellow).
• Boundary zone, share of channel depth (0.2): how close to a band a turn must form for a setup, and the zone near the opposite band used by the exit rule.
• Require outer channel in trade direction (off): adds the outer channel to the setup conditions.
• Cycle filter (Off): Off, Cycle in trade direction, or Cycle in trade direction and regular.

Display
• Centred channels (exact section) (on): shows the exact bands.
• Gap estimate and projection (on): shows the dashed estimates on the price chart.
• Drop-point estimate for comparison (off): shows the grey dotted drop-point lines in both panes.
• Status table (off): shows the table on the price chart.
• Scorecard (Inner): Inner, Middle, Outer, Highlighter or Off. The scorecard is calculated only while the status table is shown.
• Table position (Bottom right).
• Inner colour, Middle colour, Outer colour: channel colours.

Even spans entered in any span input are raised by one.


█ WHAT MAKES IT ORIGINAL

The book describes most of its method as a drawing procedure carried out by eye. This script turns that procedure into explicit rules that run on every bar:
• constant-depth bands set by a percentile of distances, rather than drawn by hand;
• the book's adjusted quadratic extrapolation;
• bending and symmetry reversal driven by measured boundary breaks inside the gap;
• the outermost-first collision rule for projections;
• the cycle highlighter with its own gap estimate;
• the chapter 4 prediction box, computed from measured half-waves and swings, with a stated test of regularity.

The bands keep a constant depth in price units. They do not widen and narrow with recent volatility, because the method reads the depth itself as the combined size of the shorter cycles.

The script adds two things the book does not contain:
• The drop-point estimator. It fills the gap from the known values that will leave each average, under a random-walk assumption. It gives a reference estimate that fits no curve.
• The scorecard. It stores every gap estimate when it is made and scores it once the true centred value is known. This shows, on any symbol and timeframe, how each estimator compares with the others, and which one the signals depend on.

Where the book gives no number, this script makes an explicit choice, and each is exposed as an input or stated here:
• the penetration tolerance;
• the shape of a bend, its exemption for the first quarter of the gap, and its four half-depth cap;
• the regularity thresholds;
• the triangular weighting of the short average;
• applying the collision rule to the projection only.


█ NOTES / LIMITATIONS

• The centred lines use later data. Each plotted point of the exact channels and the highlighter uses data from up to half a span after that point; the lines are drawn shifted back by that half span. They show where the channel was, not what was known on that bar, and they are not signals.
• Repainting by design. The dashed gap estimates and projections are recalculated and redrawn on every bar.
• Signals and the cycle filter use only estimates available at their bar. On the real-time bar a marker can appear or disappear until the bar closes.
• Window for signals and scorecard. Signals, the cycle filter and the scorecard are calculated only on the last Bars with per-bar estimates bars. Earlier bars show channels and highlighter but no markers. A full recalculation moves the start of this window, so the first markers in it can differ between loads.
• History needed. The bands need enough calculated points for the depth percentile before they render. Gap estimates and signals also need more than three times the span in history. On short histories the outer or middle channel, the signals or the highlighter can be missing.
• Too few turns. The prediction box and the regularity status need at least three confirmed highlighter turns. Turns are confirmed a number of bars after they occur, and the box's right edge is limited to 490 bars ahead.
• Linear price units. The bands have a constant depth in price units. On a logarithmic price scale they no longer look constant. Over long histories with large price changes, the rolling depth lookback keeps the depth current.
• Scorecard counts are not independent. Neighbouring bars share most of their data.
• Unpublished algorithms not included. The author's proprietary probability-based gap and turning-point algorithms, and his predictability score, were never published. They are not reproduced.
• Object and data limits. The script uses up to 5,000 bars of history references, at most 50 polylines and 5 boxes. The projection is limited to 250 bars. The script makes no requests to other symbols or timeframes.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.