All indicators
Volatility / Own pane

TTM Squeeze

John Carter's TTM Squeeze: a momentum histogram in four colours and a dot on the zero line that is red while the Bollinger Bands sit inside the Keltner Channel.

  • Squeeze
  • Updates every tick
  • ttm squeeze
  • squeeze
  • bollinger
  • keltner
  • momentum
  • histogram

By Spectral · v1.0.0

MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.

TTM Squeeze on a Spectral chart
Spectral chart with sample market data, default settings.

Overview

The TTM Squeeze by John Carter (Mastering the Trade) looks for quiet markets that are about to move. The squeeze is on while the Bollinger Bands (20 bars, 2 standard deviations) lie inside the Keltner Channel (20 bars, 1.5 ATR): volatility has contracted. The histogram measures momentum: the close against the average of the 20-bar Donchian midline and the 20-bar simple average, smoothed with a 20-bar linear regression.

How to read it

Red crosses on the zero line: the squeeze is on. Green crosses: it is off. Carter's signal is the first green cross after a run of red ones, the squeeze firing, taken in the direction of the histogram. Light blue bars: momentum above zero and rising; dark blue: above zero and falling; bright red: below zero and falling; dark red: below zero and rising. A colour change toward the dark shade often comes before the move ends.

Settings and limitations

Length (20), Bollinger width (2) and Keltner width (1.5) are Carter's settings; a wider Keltner Channel reports more squeezes. Squeeze dots switches the crosses. The six colours are appearance settings.

Notes

Formulas (StockCharts ChartSchool, TTM Squeeze; John Carter, Mastering the Trade): squeeze on when the upper Bollinger Band is below the upper Keltner Channel and the lower band above the lower channel; Bollinger = SMA(close) +- width x population standard deviation; Keltner = SMA(close) +- width x ATR (Wilder smoothing, Carter's channel; StockCharts' article describes the same 20 bars and 1.5 ATR). Momentum = linear regression value at the latest bar (least squares over Length bars) of close - ((highest high + lowest low) / 2 + SMA(close)) / 2. A bar equal to the previous one keeps the rising shade. Momentum appears after about twice Length bars. Other charting tools build the Keltner Channel differently: the common TradingView port (LazyBear's Squeeze Momentum Indicator) averages the true range with a simple average instead of Wilder's, and StockCharts' Keltner Channels use an EMA basis, so the squeeze dots there can turn on or off a few bars earlier or later; the momentum histogram uses the same formula as LazyBear's. On a long chart the squeeze crosses are drawn on the newest 4,000 bars only (Spectral keeps at most 4,000 shape markers per key); the histogram covers every bar.

Settings

Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.

SettingTypeDefaultRange or optionsWhat it does
LengthWhole number202 – 200Bars of the Bollinger Bands, the Keltner Channel and the momentum regression.
Bollinger widthNumber20.1 – 10, step 0.1Standard deviations of the Bollinger Bands.
Keltner widthNumber1.50.1 – 10, step 0.1ATR multiple of the Keltner Channel.
Squeeze dotsOn / offOn—Draw the squeeze state as a cross on the zero line of every bar.

What it draws

Lines

  • Momentumhistogram · solid · 2 px · primary · colored per bar from Momentum (4 colors)#00BCD4 #2962A8 #F85149 #8E2A2A

Markers

  • Squeezecross, tiny · colors from Squeeze (2 colors)#F85149 #3FB950

Source

Save it as ttm-squeeze.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.

// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** Spectral keeps at most 4,000 shape markers per key: squeeze dots go on the most recent bars. */
const MAX_DOTS = 4000;

/** @type {import('./spectral-indicator').IndicatorV3} */
export default {
  schemaVersion: 3,
  id: 'ttm-squeeze',
  name: 'TTM Squeeze',
  shortName: 'Squeeze',
  version: '1.0.0',
  author: 'Spectral',
  description: 'John Carter\'s TTM Squeeze: a momentum histogram in four colours and a dot on the zero line that is red while the Bollinger Bands sit inside the Keltner Channel.',
  pane: 'oscillator',
  live: { lookback: '2*length' },
  inputs: {
    length: { type: 'integer', label: 'Length', default: 20, min: 2, max: 200, description: 'Bars of the Bollinger Bands, the Keltner Channel and the momentum regression.' },
    bbMult: { type: 'number', label: 'Bollinger width', default: 2, min: 0.1, max: 10, step: 0.1, description: 'Standard deviations of the Bollinger Bands.' },
    kcMult: { type: 'number', label: 'Keltner width', default: 1.5, min: 0.1, max: 10, step: 0.1, description: 'ATR multiple of the Keltner Channel.' },
    showDots: { type: 'boolean', label: 'Squeeze dots', default: true, description: 'Draw the squeeze state as a cross on the zero line of every bar.' },
  },
  palettes: {
    momentum: { label: 'Momentum', colors: ['#00BCD4', '#2962A8', '#F85149', '#8E2A2A'] },
    squeeze: { label: 'Squeeze', colors: ['#F85149', '#3FB950'] },
  },
  plots: {
    momentum: { label: 'Momentum', color: '#00BCD4', lineWidth: 2, primary: true, style: 'histogram', palette: 'momentum' },
  },
  markers: {
    squeeze: { label: 'Squeeze', color: '#F85149', shape: 'cross', size: 'tiny', palette: 'squeeze', hideBelowBarWidth: 2 },
  },
  docs: {
    overview: 'The TTM Squeeze by John Carter (Mastering the Trade) looks for quiet markets that are about to move. The squeeze is on while the Bollinger Bands (20 bars, 2 standard deviations) lie inside the Keltner Channel (20 bars, 1.5 ATR): volatility has contracted. The histogram measures momentum: the close against the average of the 20-bar Donchian midline and the 20-bar simple average, smoothed with a 20-bar linear regression.',
    howToRead: 'Red crosses on the zero line: the squeeze is on. Green crosses: it is off. Carter\'s signal is the first green cross after a run of red ones, the squeeze firing, taken in the direction of the histogram. Light blue bars: momentum above zero and rising; dark blue: above zero and falling; bright red: below zero and falling; dark red: below zero and rising. A colour change toward the dark shade often comes before the move ends.',
    settings: 'Length (20), Bollinger width (2) and Keltner width (1.5) are Carter\'s settings; a wider Keltner Channel reports more squeezes. Squeeze dots switches the crosses. The six colours are appearance settings.',
    notes: 'Formulas (StockCharts ChartSchool, TTM Squeeze; John Carter, Mastering the Trade): squeeze on when the upper Bollinger Band is below the upper Keltner Channel and the lower band above the lower channel; Bollinger = SMA(close) +- width x population standard deviation; Keltner = SMA(close) +- width x ATR (Wilder smoothing, Carter\'s channel; StockCharts\' article describes the same 20 bars and 1.5 ATR). Momentum = linear regression value at the latest bar (least squares over Length bars) of close - ((highest high + lowest low) / 2 + SMA(close)) / 2. A bar equal to the previous one keeps the rising shade. Momentum appears after about twice Length bars. Other charting tools build the Keltner Channel differently: the common TradingView port (LazyBear\'s Squeeze Momentum Indicator) averages the true range with a simple average instead of Wilder\'s, and StockCharts\' Keltner Channels use an EMA basis, so the squeeze dots there can turn on or off a few bars earlier or later; the momentum histogram uses the same formula as LazyBear\'s. On a long chart the squeeze crosses are drawn on the newest 4,000 bars only (Spectral keeps at most 4,000 shape markers per key); the histogram covers every bar.',
  },
  calculate(ctx) {
    const { bars, inputs, ta } = ctx;
    const n = inputs.length;
    const close = ta.source(bars, 'close');
    const basis = ta.sma(close, n);
    const deviation = ta.stdev(close, n);
    const range = ta.atr(bars, n);
    const highest = ta.highest(ta.source(bars, 'high'), n);
    const lowest = ta.lowest(ta.source(bars, 'low'), n);
    const delta = close.map((value, index) => (basis[index] === null || highest[index] === null || lowest[index] === null
      ? null : value - ((highest[index] + lowest[index]) / 2 + basis[index]) / 2));
    // Least-squares line over the last n deltas (x = 0..n-1), evaluated at the newest one.
    const momentum = new Array(bars.length).fill(null);
    const sumX = (n * (n - 1)) / 2;
    const sumXX = ((n - 1) * n * (2 * n - 1)) / 6;
    const denominator = n * sumXX - sumX * sumX;
    for (let index = n - 1; index < bars.length; index += 1) {
      let sumY = 0;
      let sumXY = 0;
      let complete = true;
      for (let k = 0; k < n; k += 1) {
        const value = delta[index - n + 1 + k];
        if (value === null) { complete = false; break; }
        sumY += value;
        sumXY += k * value;
      }
      if (!complete) continue;
      const slope = (n * sumXY - sumX * sumY) / denominator;
      const intercept = (sumY - slope * sumX) / n;
      momentum[index] = intercept + slope * (n - 1);
    }
    const colors = momentum.map((value, index) => {
      if (value === null) return null;
      const previous = index > 0 ? momentum[index - 1] : null;
      const rising = previous === null || value >= previous;
      return value >= 0 ? (rising ? 0 : 1) : (rising ? 3 : 2);
    });
    const squeeze = [];
    if (inputs.showDots) {
      for (let index = Math.max(0, bars.length - MAX_DOTS); index < bars.length; index += 1) {
        if (basis[index] === null || deviation[index] === null || range[index] === null) continue;
        const on = basis[index] + inputs.bbMult * deviation[index] < basis[index] + inputs.kcMult * range[index]
          && basis[index] - inputs.bbMult * deviation[index] > basis[index] - inputs.kcMult * range[index];
        squeeze.push({ index, value: 0, palette: on ? 0 : 1 });
      }
    }
    return { plots: { momentum }, colors: { momentum: colors }, markers: { squeeze } };
  },
};

Adapt it with an LLM

Paste this into your assistant and replace the second-to-last line with the change you want.

Start from this Spectral custom indicator: https://spectral.trade/indicators/ttm-squeeze.js
Format reference: https://spectral.trade/docs/custom-indicators.llm.md
Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match.
Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow.
Change I want: <describe the change>
Answer with the complete file in one code block, ready to save as <id>.js.