Indicators··6 min read

Inside/Outside Bar Highlighter

1 references, link-verified · inline [n] markersEditor of record: Shane CantyStandards review editorial standard · audit log

Inside bars and outside bars are foundational price action patterns [1] that signal market consolidation and volatility expansion. An inside bar represents a contraction in price range, where both high and low remain within the previous bar's boundaries; an outside bar shows range expansion, with both high and low breaking beyond the previous bar's extremes [1]. Traders use these patterns to identify potential breakout setups, support/resistance tests, and moments of reduced liquidity. This indicator automates the visual identification of both patterns on any timeframe.

The indicator compares each bar's high and low against the prior bar's extremes. When a new bar's range sits entirely within the previous bar's range, it triggers as an inside bar. Conversely, when a bar simultaneously breaks both the prior high and prior low, it registers as an outside bar. The tool highlights these bars in real time, eliminating manual scanning and reducing false signals caused by subjective interpretation.

Inside bar formation often precedes directional moves because price compression (low volatility) typically gives way to expansion (high volatility) [2]. Outside bars, meanwhile, can signal strong directional intent in either direction, particularly when they occur after consolidation phases. Neither pattern is a standalone signal: they work best alongside support/resistance levels, trend context, and volume confirmation. Practitioner convention commonly applies these patterns in scalping, swing trading, and mean-reversion setups on intraday and daily timeframes [2].

//@version=6
indicator("Inside/Outside Bar Highlighter", overlay=true)

// User inputs
showOutsideBars = input(true, "Show Outside Bars")
showInsideBars = input(true, "Show Inside Bars")
outsideBarColor = input(color.new(color.red, 80), "Outside Bar Color")
insideBarColor = input(color.new(color.blue, 80), "Inside Bar Color")
useBarColor = input(true, "Color Bars (true) or Background (false)")

// Detect inside and outside bars
isOutsideBar = high > high[1] and low < low[1]
isInsideBar = high < high[1] and low > low[1]

// Determine which color to apply
barHighlightColor = showOutsideBars and isOutsideBar ? outsideBarColor : 
                    showInsideBars and isInsideBar ? insideBarColor : na

// Apply coloring to bars or background
if useBarColor
    barcolor(barHighlightColor, title="Bar Color")
else
    bgcolor(barHighlightColor, title="Background Color")

How the code works

The script registers as an overlay indicator, displaying on top of price data rather than in a separate panel. It accepts four user-configurable inputs: toggles to enable or disable each pattern type, and color pickers for each with default transparency (alpha 80 out of 100).

The core logic compares current-bar extremes to the prior bar's extremes using bracket notation. high[1](#ref-1) and low[1](#ref-1) reference the previous bar's high and low. An outside bar is detected when high > high[1](#ref-1) and low < low[1](#ref-1) simultaneously. An inside bar requires high < high[1](#ref-1) and low > low[1](#ref-1). These are strict comparisons: a bar whose high equals the prior high, or whose low equals the prior low, will not trigger either pattern.

A nested ternary operator assigns the appropriate highlight color. If outside bars are enabled and the current bar meets outside criteria, it uses the outside color; otherwise, if inside bars are enabled and inside criteria are met, it uses the inside color; otherwise it returns na (no color). This ensures only one pattern highlights per bar.

The final step applies the color either to the bar itself (barcolor()) or to the background (bgcolor()) based on user preference. This flexibility accommodates different chart aesthetics and helps avoid visual clutter on crowded timeframes.

Reading it on a chart

An inside bar will appear colored (default blue) entirely within the previous bar's range. Traders often watch for inside bar breakouts: a series of contracting bars followed by a sharp directional close, which can signal accelerating momentum [3]. The pattern carries more weight after substantial prior swings; isolated inside bars in a trending market often resolve without consequence.

An outside bar (default red) encompasses the prior bar completely. Its appearance frequently marks a turning point or trend continuation, depending on context. A large outside bar early in a trend can confirm strength; one appearing after consolidation might represent a false breakout that reverses intrabar or on the next candle.

Neither pattern should guide entries alone. Combine them with price structure (swing highs and lows), volume analysis, or momentum oscillators. On lower timeframes (1-5 minutes), noise intensifies and false patterns proliferate; higher timeframes (hourly and above) tend to yield more reliable sequences.

Limitations

This indicator is purely pattern recognition and carries significant blind spots. Inside bars and outside bars appear frequently across all timeframes and market regimes [2]; the majority resolve without predictive value, making them unreliable as standalone signals. A single inside bar on a 1-minute chart carries almost no statistical edge; even on daily charts, a pattern appearing 50 times per year across multiple assets will include many false breakouts.

The indicator has no concept of context: it does not distinguish between a small inside bar in a strong trend (likely mean-reversion noise) and a compression before a major breakout. It contains no volume confirmation, volatility scaling, or regime detection. It repaints only in the sense that a newly-forming bar will not highlight until completion; prior bars' classifications remain fixed.

Lookback bias is substantial. Historical backtests of inside bar breakout strategies often show inflated win rates because they ignore slippage, execution delays, and the high proportion of trades that fail near open or close. Trader convention varies: some require strictly inside bars (high strictly less than high[1]); others accept bars failing to make new extremes. This indicator uses strict comparison; alternative definitions yield different frequencies.

The indicator provides no exit signals, profit targets, or stop-loss levels. It highlights entry opportunity only; position management and risk control remain the trader's sole responsibility.

Key definitions

Inside Bar: A price bar whose high is lower than the previous bar's high and whose low is higher than the previous bar's low, representing a contraction in trading range.

Outside Bar: A price bar whose high exceeds the previous bar's high and whose low falls below the previous bar's low, representing an expansion in trading range.

Volatility Expansion: An increase in the distance between a bar's high and low, or between successive bars' ranges, often preceding directional moves.

Support/Resistance Level: A price level at which buying or selling pressure has historically concentrated, often coinciding with prior swing highs or lows.

Breakout: A price move that closes beyond a previously established high or low, often triggering stop-loss orders and directional trading.

Mean Reversion: The tendency of price to move back toward an average or equilibrium level after moving away from it, common in consolidation phases.

References

  1. Wikipedia, "Candlestick Pattern," https://en.wikipedia.org/wiki/Candlestick_pattern

  2. Nison, Steve. Japanese Candlestick Charting Techniques. Prentice Hall, 1991.

  3. Investopedia, "Inside Bar Definition," Technical Analysis Education


Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.

Last reviewed by the PropLedger research pipeline: 2026-10-11. Educational research on historical data, not financial advice.

Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard. Found an error? Email support@prop-ledger.org and the paper is corrected or withdrawn.