barsPattern

The Bars Pattern tool lets you copy a past section of price bars and project it forward in time. Traders use it to compare historical moves with current market action, spotting repetition, symmetry, or possible fractal behavior.

Syntax

barsPattern(fromPoint, toPoint, styles?)

Parameters

fromPoint (PricedData) · First anchor (time & price), where the bar pattern starts. toPoint (PricedData) · Second anchor (time & price), where the copied segment ends. styles (BarsPatternStyleOverrides) · Customization options:

  • fillBackground (boolean) · Fill the background of the projected bars.

  • transparency (number) · Background transparency (0–100).

  • showLabels (boolean) · Display labels on pattern anchors.

  • line (LinesLevels without coeff) · Style of projected bar edges (linestyle, linewidth, color).

  • background (RGBAColor | BaseColors) · Fill color behind the projected bars.

Return Value

(string) · The drawing ID of the created Bars Pattern.

Example

Every 70 candles, project a Bars Pattern using a past 40-bar swing as reference.

//@version=1
init = () => {
  indicator({ onMainPanel: true, format: 'inherit' });
};

onTick = () => {
  if (index % 70 === 0) { // draw every 70 bars
    // 1) Select anchors for the copied range
    const from = newPoint(time(110), closeC(110)); // pattern start
    const to   = newPoint(time(70),  closeC(70));  // pattern end

    // 2) Style configuration
    const style = {
      fillBackground: true,
      transparency: 80,
      showLabels: true,
      line: { linestyle: 0, linewidth: 2, color: color.orange },
      background: color.rgba(255, 165, 0, 0.2)
    };

    // 3) Draw Bars Pattern
    barsPattern(from, to, style);
  }
};

Tips

  • Use swings with clear structure (trending or corrective) to compare with current action.

  • Works well when markets show fractal behavior (similar patterns repeating at different scales).

  • Great for visual experiments when testing if history “rhymes.”

Warning

  • Copying random sideways action won’t be useful — always pick meaningful moves.

Good Practice

  • Keep the projection lightly styled (semi-transparent) so it doesn’t overwhelm the live bars.

  • Overlay multiple bars patterns from different timeframes to see if they align.

Last updated