Indicator · Pine Script v5 · On the chart

Candlestick - Inside Bar Pattern

by harryguiacorn· code credited to FxCloudTrader

Candlestick - Inside Bar Pattern is an overlay indicator that identifies inside bar setups across three consecutive candles.

View on GitHub

GitHub stars219on the repository
Pine versionv5runs as is
Lines of code30
Settings2inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago8 May 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

30 lines of Pine Script v5 from CandlestickInsideBar.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

CandlestickInsideBar.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FxCloudTrader

//@version=5
// This is a 3-bar formation setup
// The range of -1 bar is capped within the -2 bar's
// The direction of current bar dictates the direction of the signal
indicator(title="Candlestick - Inside Bar Pattern", shorttitle="Inside Bar", overlay=true, precision = 0)

getRange(x, y) => math.abs(x - y)

bool enableInsideBar = input.bool(true, '2. Enable Inside Bar signal')
int minimumCloseTriggerCandle = input.int(50, "Minimum Pencentage of Close of Price Candle Range", step = 5)// The default is 50%, meaning the closing price needs to be above 50% of its price range for a bullish candle

range_bar_2 = getRange(high[2], low[2])
range_bar_1 = getRange(high[1], low[1])

bool insbar_cond_up = low[2] < low[1] and high[2] > high[1] and close > open //and close >= hl2
bool insbar_cond_dn = low[2] < low[1] and high[2] > high[1] and close < open //and close <= hl2

bool weakUp = close < hl2
bool weakDn = close > hl2

// if insbar_cond_up and weakUp
//     label.new(bar_index, na, "Weak", yloc = yloc.belowbar, style = label.style_none, textcolor = color.red, size = size.normal)
// if insbar_cond_dn and weakDn
//     label.new(bar_index, na, "Weak", yloc = yloc.abovebar, style = label.style_none, textcolor = color.red, size = size.normal)

plotshape(insbar_cond_up, "Inside Bar Bullish", shape.cross, location.belowbar, color = color.new(weakUp?color.yellow:color.black, 50), size = size.auto, display = enableInsideBar?display.all:display.data_window)
plotshape(insbar_cond_dn, "Inside Bar Bearish", shape.cross, location.abovebar, color = color.new(weakDn?color.yellow:color.black, 50), size = size.auto, display = enableInsideBar?display.all:display.data_window)

Overview

Candlestick - Inside Bar Pattern detects when the price range of the preceding bar is completely contained within the range of the bar prior to it. The direction of the active candle determines whether a bullish or bearish signal cross is plotted above or below the bar. Signal crosses are visually color-coded to distinguish weaker setups where price closes past the midpoint. Input options allow users to toggle signal visibility.

Details

Published by

harryguiacorn on GitHub

Code credit

FxCloudTrader, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Candlestick patterns, Breakout

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

bollingerbollinger-bandbollinger-bandsichimokuichimoku-cloudichimoku-indicatorpinepinescriptpinescript-guidespinescript-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
2. Enable Inside Bar signalbooltrueenableInsideBar
Minimum Pencentage of Close of Price Candle Rangeint50minimumCloseTriggerCandle
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Raschke Patterns

by TradersPost
218 stars

This overlay indicator marks Linda Raschke short-term bar setups on the price chart. It flags Turtle Soup and Turtle Soup plus one false breakouts of a prior extreme, 80-20 bars, inside bars, failed inside-bar breakouts, outside up and down bars, NR4 and NR7 c

Indicator v6 Candlestick patternsBreakout Repaints
Updated 3 months ago · None stated GitHub repository of Raschke Patterns

Five-in-one Strategy

by capissimo
114 stars

Five-in-one Strategy combines five analytical tools into a single price chart overlay: the Dual Thrust Trading Algorithm (DTTA), Semafore, HalfTrend, Nick Rypock Trailing Reverse, and Tweezer or Kangaroo Tail candlestick patterns. It generates trade signals us

Indicator v4 TrendBreakout Repaints
Updated 1 year ago · None stated GitHub repository of Five-in-one Strategy
46 stars

This indicator identifies inside bars and outside bars, classifying each by close direction as bullish or bearish. It tracks cumulative occurrences and evaluates how often subsequent price action breaks the high or low of each pattern. A summary table drawn on

Indicator v5 Candlestick patternsScreeners & dashboards
Updated 7 weeks ago · None stated GitHub repository of Inside bar/outside bar - stats
32 stars

Ghost Channels fits dynamic parallel trend channels over a configurable lookback window using linear regression or pivot swing methods. It layers confirmation signals onto the channel geometry, detecting candlestick pattern reactions at the rails, volume-confi

Indicator v6 TrendBreakout
Updated 2 days ago · MIT GitHub repository of Ghost Channels [mph1nance]

Zen Z Bars V1

by Zen-Tim
29 stars

Zen Z Bars V1 analyzes bar-by-bar price action, candle range expansion, and internal bar strength (IBS). It identifies breakouts, inside and outside bars, climax candles based on range expansion factors, and tiered range multiple bars. The indicator draws brea

Indicator v5 Candlestick patternsBreakout
Updated 2 weeks ago · MIT GitHub repository of Zen Z Bars V1
23 stars

Point-Clip Unified Indicator plots breakout and directional labels on the price chart. It scores volume spikes against a volume average, range or opening-range breaks, optional VWAP or session-anchored VWAP, fast and slow EMA trend, and a higher-timeframe EMA

Indicator v6 BreakoutVolume Repaints
Updated 3 weeks ago · Custom licence GitHub repository of Point-Clip Unified Indicator

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers