disjointChannel

Draw a slanted price channel where the second line is offset by a custom distance (not necessarily parallel to a specific pivot like in parallelChannel). It’s perfect for visualizing things like:

  • Trend corridors (up or down)

  • Volatility envelopes around a move

  • “No‑trade” lanes while waiting for a breakout

  • Back‑testing a “walk the channel” strategy

think of it as two rails that follow your chosen slope, with the gap set by a third point you pick on the chart.

Syntax

disjointChannel(fromPoint, toPoint, offsetPoint, styles?, text?)

Parameters

  • fromPoint: First anchor for the channel’s direction. Build it with newPoint(time, price), e.g. newPoint(time(30), low(30)).

  • toPoint: Second anchor that sets the slope/direction of the channel. Also created with newPoint(time, price), e.g. newPoint(time(10), high(10)).

  • offsetPoint: A third point that defines the distance (gap) between the main line and the offset line. Use newPoint(time, price), e.g. newPoint(time(0), closeC(0)).

Tip: choose a point that represents how “wide” you want the channel to be (like the most recent swing on the other side).

  • styles (optional) Visual options you can pass as an object:

    • linecolor (string | RGBA) · Color of the base/parallel lines.

    • linestyle (number) · Line style (e.g., solid/dashed).

    • linewidth (number) · Line width.

    • extendLeft (boolean) · Extend channel to the left.

    • extendRight (boolean) · Extend channel to the right.

    • fillBackground (boolean) · Fill the channel area.

    • backgroundColor (string | RGBA) · Fill color.

    • transparency (number) · Fill transparency (higher = more transparent).

    • showBarsRange (boolean) · Show bars count.

    • showDateTimeRange (boolean) · Show date/time span.

    • showPriceRange (boolean) · Show price range stats.

    • showPrices (boolean) · Show prices on labels.

    • leftEnd (number) · Left line ending style.

    • rightEnd (number) · Right line ending style.

    • labelVisible (boolean) · Must be true to show the text you pass.

    • labelBold (boolean) · Label bold text.

    • labelItalic (boolean) · Label italic text.

    • labelFontSize (number) · Label font size.

    • labelTextColor (string | RGBA) · Label color.

    • labelHorzAlign (string) · Label horizontal align.

    • labelVertAlign (string) · Label vertical align.

    • textcolor (string | RGBA) · Line text color (for stats/labels).

    • fontsize (number) · Line font size.

    • bold (boolean) · Line label bold.

    • italic (boolean) · Line label italic.

  • text (optional): Short label for the drawing (e.g., "Disjoint Channel"). Visible only if showLabel: true.

Return Value

  • string — The unique drawing id you can later use with updateDrawingById(id, data) or deleteDrawingById(id).

Example

This script draws a disjoint channel every 40 candles. We:

  • Use an old low and a recent high to set the slope

  • Use the current close as the offset to define the channel’s width

Result

Tips

  • Mix and match pivots: for an uptrend, try low→high for the slope and use a recent low as offsetPoint to size the lower rail naturally.

  • To mimic a volatility band, set offsetPoint near a “far” swing; for a tight corridor, pick something close to the base line.

  • If you want a live‑updating channel without stacking drawings, store the returned id and call updateDrawingById(id, [p1, p2, offset]) instead of creating new ones.

Warning

Good Practice

Last updated