What Inside/Outside Bar Highlighter does
Inside/Outside Bar Highlighter is a free indicator by DinexSpace for MT5 and TradingView. Highlights inside bars and outside bars.
Enable JavaScript to see the chart.
Chart powered by TradingView Lightweight Charts™ (Apache-2.0 license). tradingview.com
The candles and indicator lines above come straight from the MT5 version running in the Strategy Tester (XAUUSD H1); nothing is recalculated in the browser. Press ▶ to replay bar by bar.
MT5 version
Inside/Outside Bar Highlighter colours two common candle patterns so they are easy to spot on any chart:
- Inside bar: the bar's high is below the previous high and its low is above the previous low. The range has contracted inside the previous bar.
- Outside bar: the bar's high is above the previous high and its low is below the previous low. The range has expanded beyond the previous bar on both sides.
TradingView version
Inside/Outside Bar Highlighter colours two common candle patterns so they are easy to spot on any chart:
- Inside bar: the bar's high is below the previous high and its low is above the previous low. The range has contracted inside the previous bar.
- Outside bar: the bar's high is above the previous high and its low is below the previous low. The range has expanded beyond the previous bar on both sides.
When to use it
Use it to spot price compressing before a breakout.
Features and modes
Inside/Outside Bar Highlighter has 7 documented features, listed below.
MT5 version
How it works
- The indicator draws a coloured candle on top of each matching bar. Inside bars are amber and outside bars violet by default.
- The colours are neutral on purpose: they mark the pattern, not a direction. They can be changed on the Colors tab.
- An option counts equal highs or lows as well (≤ and ≥ instead of < and >), which suits instruments with coarse price steps.
- All other bars are left untouched, so your normal chart colours stay as they are.
TradingView version
How it works
- Inside bars are coloured amber and outside bars violet by default. The colours are neutral on purpose: they mark the pattern, not a direction.
- An option counts equal highs or lows as well (≤ and ≥ instead of < and >), which some traders prefer on instruments with coarse price steps.
- Mother bar range: when an inside-bar sequence starts, the high and low of the bar before it (the "mother bar") are drawn as dashed lines. They extend for as long as the following bars stay inside that range. You choose how many past ranges to keep.
Parameters
Inside/Outside Bar Highlighter has 3 inputs in the MT5 version and 5 in the TradingView version; every input and its default is listed below.
MT5 version
Inside bars on/off, outside bars on/off, count equal highs/lows.
TradingView version
- Patterns: inside bars on/off and colour, outside bars on/off and colour, count equal highs/lows.
- Mother bar range: on/off, number of ranges kept.
| Input | Default | Label in MT5 |
|---|---|---|
InpInside | true | Inside bars (first colour) |
InpOutside | true | Outside bars (second colour) |
InpEqual | false | Count equal highs/lows |
| Input | Default |
|---|---|
| Patterns | |
| Inside bars | true |
| Outside bars | true |
| Count equal highs/lows (≤ / ≥) | false |
| Mother bar range | |
| Draw mother bar high/low while inside bars continue | true |
| Ranges kept | 20 |
Signals
Inside/Outside Bar Highlighter does not generate buy or sell signals. It is an analysis tool: you read what it plots and make your own decisions.
Alerts
Yes. Inside/Outside Bar Highlighter has built-in alerts: TradingView – alert conditions for Create Alert.
- Alerts can notify you when an inside or outside bar forms.
Buffers for Expert Advisors
Yes. The MT5 version of Inside/Outside Bar Highlighter exposes its plots as indicator buffers that an EA can read with iCustom and CopyBuffer: Pattern Open, Pattern High, Pattern Low, Pattern Close.
- The four candle values are indicator buffers. Another program can read them with iCustom: a non-empty value means the bar matched.
Timeframes and markets
Inside/Outside Bar Highlighter sets no timeframe limit in its code: it runs on any chart timeframe and on the symbol of the chart it is attached to.
Limitations
Inside/Outside Bar Highlighter is an analysis tool, not a trading system. Its documented limitations are listed below.
MT5 version
- The current bar can change pattern until it closes.
- The patterns describe the shape of the candles only. The indicator does not judge whether a pattern is meaningful.
The indicator only colours candles. It does not trade, give signals or use DLLs or web requests.
TradingView version
- The current bar can change pattern until it closes. Use alerts "once per bar close" for confirmed patterns.
- The patterns describe the shape of the candles only. The script does not judge whether a pattern is meaningful and does not say when to buy or sell.
This script is a chart-reading aid only. It does not give trade signals or investment advice.
Pine Script code
Paste the whole script into the Pine Editor on TradingView.
inside_outside_bars.pine · 54 lines//@version=6
// DinexSpace | Inside/Outside Bar Highlighter
// Colours inside bars (range fully within the previous bar) and outside bars (range fully covering the
// previous bar) so these compression and expansion candles are easy to spot. Optionally draws the high and
// low of the "mother" bar of an inside-bar sequence. It only colours candles; it gives no trade signals.
// Free and open source. License: MIT. (c) 2026 DinexSpace
indicator("DinexSpace | Inside/Outside Bar Highlighter", shorttitle = "DNX In/Out Bars", overlay = true, max_lines_count = 200)
// ===== Brand colours (neutral on purpose: the colour says "pattern", not "direction") =====
C_AMBER = #FFB000 // inside bars
C_VIOLET = #8E7CFF // outside bars
// ===== Inputs =====
GRP_P = "Patterns"
useIn = input.bool(true, "Inside bars", inline = "i", group = GRP_P)
colIn = input.color(C_AMBER, "", inline = "i", group = GRP_P)
useOut = input.bool(true, "Outside bars", inline = "o", group = GRP_P)
colOut = input.color(C_VIOLET, "", inline = "o", group = GRP_P)
strictEq = input.bool(false, "Count equal highs/lows (≤ / ≥)", group = GRP_P)
GRP_M = "Mother bar range"
showMom = input.bool(true, "Draw mother bar high/low while inside bars continue", group = GRP_M)
keepMom = input.int(20, "Ranges kept", minval = 1, maxval = 100, group = GRP_M)
bool inside = strictEq ? (high <= high[1] and low >= low[1]) : (high < high[1] and low > low[1])
bool outside = strictEq ? (high >= high[1] and low <= low[1] and not inside) : (high > high[1] and low < low[1])
barcolor(useIn and inside ? colIn : useOut and outside ? colOut : na, title = "Pattern colour")
// Mother bar: the bar before the first inside bar of a sequence; its range stays drawn while bars stay inside it.
var line mHi = na
var line mLo = na
var float mH = na
var float mL = na
var array<line> kept = array.new<line>()
if showMom and inside and not inside[1]
mH := high[1]
mL := low[1]
mHi := line.new(bar_index - 1, mH, bar_index, mH, color = color.new(colIn, 30), style = line.style_dashed)
mLo := line.new(bar_index - 1, mL, bar_index, mL, color = color.new(colIn, 30), style = line.style_dashed)
kept.push(mHi)
kept.push(mLo)
while kept.size() > keepMom * 2
line.delete(kept.shift())
else if showMom and not na(mH) and high <= mH and low >= mL
// still inside the mother bar: extend its range
mHi.set_x2(bar_index)
mLo.set_x2(bar_index)
else
mH := na
mL := na
alertcondition(inside, "Inside bar", "{{ticker}}: inside bar formed")
alertcondition(outside, "Outside bar", "{{ticker}}: outside bar formed")
Inside/Outside Bar Highlighter FAQ
Inside/Outside Bar Highlighter is free, runs on MT5 and TradingView and does not place trades.
Is Inside/Outside Bar Highlighter free?
Yes. Inside/Outside Bar Highlighter is free to download from this page with no sign-up, and the download includes the full source code.
Which platforms does Inside/Outside Bar Highlighter run on?
Inside/Outside Bar Highlighter is available for MetaTrader 5 (MQL5) and TradingView (Pine Script v6).
Does Inside/Outside Bar Highlighter give buy and sell signals?
Inside/Outside Bar Highlighter does not generate buy or sell signals. It is an analysis tool: you read what it plots and make your own decisions.
Does Inside/Outside Bar Highlighter have alerts?
Yes. Inside/Outside Bar Highlighter has built-in alerts: TradingView – alert conditions for Create Alert.
Can an EA read Inside/Outside Bar Highlighter?
Yes. The MT5 version of Inside/Outside Bar Highlighter exposes its plots as indicator buffers that an EA can read with iCustom and CopyBuffer: Pattern Open, Pattern High, Pattern Low, Pattern Close.
Which timeframes does Inside/Outside Bar Highlighter work on?
Inside/Outside Bar Highlighter sets no timeframe limit in its code: it runs on any chart timeframe and on the symbol of the chart it is attached to.
Does Inside/Outside Bar Highlighter place trades?
No. It is a read-only indicator: it only reads market data and shows the result on the chart or writes it to a file. The source contains no calls that open, close or modify orders.
How do I install Inside/Outside Bar Highlighter?
Download the .zip and follow the step-by-step installation guide for MT5 and TradingView: https://indicators.dinexspace.com/install-guide/
Measured win rates (backtest)
Being measured: the Python measurement does not yet match the MT5 signal count; being reconciled.
- Costs: Real spread of an ECN-type MT5 account, no commission.
- Data source: MT5 tick data (BNB: Binance spot).
TradingView H4/D1 bars may follow the exchange time zone of the TradingView symbol, not the MT5 server time (UTC) used for the measurement; sessions and the H4 trend may differ on the Pine version. Same signals on TradingView not checked yet.
Past test statistics are not a promise of future results.