OPEN-SOURCE SCRIPT

Auto Trend Channels [AFD]

3 574
A trend channel is only worth drawing if price actually respected it. This script builds every channel from three confirmed swing pivots, checks each bar between the anchors against the boundaries, and puts the channel on your chart only once a bar has closed inside it. Then it marks, on the drawing itself, the exact bar it became usable - so you always know which part of the channel is history and which part you could have acted on.

WHAT IT DOES

Auto Trend Channels finds parallel channels from confirmed swing pivots and follows each one through its whole life: accepted, broken, retouched, returned or expired.

  • Three pivots, exact geometry - a rising channel joins two rising swing lows and runs its upper boundary parallel through the swing high between them. A falling channel joins two falling swing highs, with the parallel through the swing low between. No regression fit, no approximate parallels.
  • Every bar between the anchors is checked - a candidate is rejected if any bar in its span pokes past a boundary by more than your Containment allowance. Its width has to sit between your Minimum and Maximum width, both measured in units of the chart's own average range, frozen when the channel is built.
  • Usable means a bar closed inside it - a channel is drawn only after a confirmed close lands between its boundaries. The dotted vertical Known line marks that bar.
  • One active channel per layer - a newer candidate never replaces an intact channel. Turn on Longer swing channel for a second, larger layer on the same timeframe, drawn heavier and fainter so the two stay tellable apart.


HOW A CHANNEL LIVES AND DIES

  • Active - solid boundaries in the rising or falling colour, shaded inside, extending to the current bar. The label at the right edge reads the direction and Active.
  • Close outside - the first confirmed close beyond a boundary, past your Close allowance, starts a return watch. The channel switches to the history colour, goes dashed, loses its shading, and its label reads Watching above or Watching below. It keeps extending while the watch runs.
  • Boundary retouch - the first later bar whose high or low reaches the broken boundary while the close stays outside gets a one-time mark on that channel. Recorded once, never counted or rated.
  • Returned inside - a confirmed close back between the boundaries within the watch window finishes the channel as Returned inside. A finished channel never reactivates.
  • Watch ended - no close back inside within the window, and the channel is finished with its right edge frozen where it ended. Separately, once a channel's first anchor passes your horizon it is retired and leaves the chart, whatever state it was in.


Finished channels stay on the chart up to your Retained channels count, dashed and grey, so you can see what each channel did after it broke. Channels hidden by that count keep running their watch and still alert.

WHAT YOU GET ON THE CHART

  • Upper and lower boundaries, with an optional midpoint and quarter lines.
  • The Known marker on a dotted vertical line at the acceptance bar.
  • Event labels at the bar that produced them, offset clear of the candles: Close above, Close below, Boundary retouch, Returned inside.
  • Optional A, B and C markers on the three source pivots.
  • An optional Forming channel view: the candidate a layer is currently building, dotted, faint and labelled as not accepted. Off by default, because a candidate can change or vanish before it is accepted.
  • A corner notice stating linear-price geometry and confirmed-pivot delay, with an optional status panel: per-layer state, live boundary prices, watch counts and how many sets are drawn.
  • Nine colour themes, including Paper for light charts and a Colourblind safe palette built on the published Okabe-Ito blue and vermilion, plus Custom pickers.
  • Three display switches - Channel labels, Channel fill and Corner table - to strip the drawing down to the lines alone when you want a clean chart.


ALERTS AND THE DATA WINDOW

Ten named alert conditions - Formed, Close above, Close below, Returned inside and Boundary retouch, for each layer - plus one combined dynamic alert that lists every enabled event on the bar with its layer, the channel's anchor timestamps and its raw boundaries. Each alert switch gates both the named condition and the combined message. Twenty Data Window plots expose the live upper, mid and lower values, the acceptance bar, the event flags and the watch counts, so every number on the chart can be read and exported.

SETTINGS WORTH KNOWING FIRST

Swing length sets how many bars either side confirm a pivot: raise it for fewer, larger, later channels, lower it for more, smaller, sooner ones. Pivots searched is how far back each construction reaches. Containment allowance, Minimum width and Maximum width are all multiples of the average true range frozen at construction, so they carry across symbols and timeframes without retuning. Close allowance is how far a close must clear a boundary before it counts as outside; 0 accepts any close beyond. Return watch is how many bars a broken channel is watched for a close back inside. Most tooltips end with a concrete example of what changing that setting does.

WHAT IT WILL NOT DO

It is not a signal tool. A channel is a description of where price has already been, and a break, a retouch or a return is a description of a close that already happened. Nothing here is an entry, an exit, a target, a probability or evidence of an edge, and no channel is ranked against another. Retouches are marked, never counted.

WHAT IS DISCLOSED RATHER THAN HIDDEN

  • Channels appear late by design. A pivot confirms Swing length bars after it prints, and a channel is drawn only after a bar closes inside it, so a new channel first appears drawn back over earlier anchors. The Known marker shows exactly where the usable part starts: left of it is where the geometry came from, not something you could have traded.
  • Linear-price geometry. Boundaries are parallel in price per bar. On a logarithmic price axis they are not log-space parallels, and the script cannot detect your axis setting. Slope is per bar, so a channel keeps its slope straight across a weekend gap.
  • Standard time-based charts only. Renko, Kagi, Range, tick and other nonstandard charts get a corner warning and no channels.
  • Reconstruction can change with loaded history, session settings, data adjustments or inputs. Whether this script repaints has not been observed on a replay and is not claimed here either way; confirm it with the bar-replay tool on your own symbol and timeframe.
  • No request.*() calls, no higher-timeframe data, no volume. Everything is computed from the chart's own bars.


ORIGINALITY AND CREDIT

Most auto-channel scripts fit a regression line and offset it, or join two points and draw a parallel at a fixed distance. This one builds exact three-pivot geometry, validates the full span between the anchors, waits for a confirmed close inside before it calls the channel usable, marks that bar on the drawing, and follows the channel through a bounded watch after it breaks. The geometry, engine and label patterns are adapted from Auction Foundry's own Auto Trendlines, Classical Auto Chart Patterns and Zone Forge.

Open source under the Mozilla Public License 2.0. (c) Auction Foundry.

This indicator describes channel geometry built from your chart's own price history. It is not a forecast, not a signal, and not financial advice.

כתב ויתור

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