All indicators
Patterns & signals / Price pane

Inside Bars

Marks completed bars whose high and low sit inside the previous bar.

  • IB
  • Updates at bar close
  • inside bar
  • candlestick pattern
  • compression
  • breakout
  • price action

By Spectral examples · v1.0.1

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

Inside Bars on a Spectral chart
Spectral chart with sample market data, default settings.

Overview

A dot under every bar whose range is contained in the previous bar's range.

How to read it

Clusters of inside bars show compression; a break of the enclosing bar often starts the next move.

Settings and limitations

Lower Max range ratio to mark only tight inside bars. Turn on Regular session only to ignore pre-market and after-hours bars.

Notes

Marks completed bars only (live: none), so the forming bar never flickers in and out.

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
Max range ratioNumber10.1 – 1, step 0.05Largest inside-bar range as a share of the previous bar range. 1 marks every inside bar; lower values mark only tight ones.
Regular session onlyOn / offOff—Mark only regular-session bars: 09:30 to 16:00 New York time, to 13:00 on early-close days.

What it draws

Markers

  • Inside bardot, radius 4#58A6FF

Source

Save it as inside-bars.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
/** @type {import('./spectral-indicator').IndicatorV1} */
export default {
  schemaVersion: 1,
  id: 'inside-bars',
  name: 'Inside Bars',
  shortName: 'IB',
  version: '1.0.1',
  author: 'Spectral examples',
  description: 'Marks completed bars whose high and low sit inside the previous bar.',
  pane: 'price',
  live: 'none',
  inputs: {
    maxRatio: { type: 'number', label: 'Max range ratio', default: 1, min: 0.1, max: 1, step: 0.05, description: 'Largest inside-bar range as a share of the previous bar range. 1 marks every inside bar; lower values mark only tight ones.' },
    regularOnly: { type: 'boolean', label: 'Regular session only', default: false, description: 'Mark only regular-session bars: 09:30 to 16:00 New York time, to 13:00 on early-close days.' },
  },
  markers: { inside: { label: 'Inside bar', color: '#58A6FF', radius: 4 } },
  docs: {
    overview: 'A dot under every bar whose range is contained in the previous bar\'s range.',
    howToRead: 'Clusters of inside bars show compression; a break of the enclosing bar often starts the next move.',
    settings: 'Lower Max range ratio to mark only tight inside bars. Turn on Regular session only to ignore pre-market and after-hours bars.',
    notes: 'Marks completed bars only (live: none), so the forming bar never flickers in and out.',
  },
  calculate(ctx) {
    const { bars, inputs, time } = ctx;
    const inside = [];
    for (let index = 1; index < bars.length; index += 1) {
      const bar = bars[index];
      const previous = bars[index - 1];
      if (inputs.regularOnly && !time.isRegularSession(bar)) continue;
      const previousRange = previous.high - previous.low;
      if (previousRange <= 0) continue;
      const contained = bar.high <= previous.high && bar.low >= previous.low;
      if (contained && (bar.high - bar.low) / previousRange <= inputs.maxRatio) inside.push({ index, value: bar.low });
    }
    return { markers: { inside } };
  },
};

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/inside-bars.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.