PipLedger
Today's forex newsNFP, CPI, FOMC and other high-impact eventsEconomic calendarCalendar →

Inside bar strategy: breakout rules, a worked example and a free Pine Script

An inside bar is a candle that stays completely within the range of the candle before it. It's a pause: the market has stopped going anywhere for a moment, and when it breaks out of the bigger candle's range, the move can be quick. This guide explains the pattern, rules for trading the breakout with stop orders, a worked EURUSD example on the 4-hour chart and a free TradingView script.

By M. A. Horaira. Updated 10 October 2026. 9 minute read.

The rules at a glance

  • The pattern: an inside bar: a candle whose high is below the previous candle's high and whose low is above its low; the previous candle is the mother bar, at least 0.5 × ATR tall
  • Entry: a buy stop just above the mother bar's high (sell stop just below its low), a twentieth of the ATR beyond it
  • Filter: with the trend filter on (the default), only the order in the direction of the 200 EMA; with it off, both orders, and when one fills the other is cancelled
  • Stop loss: just beyond the other side of the mother bar (or of the inside bar)
  • Target and expiry: twice the risk (2R); unfilled orders are cancelled after 3 candles

What an inside bar is

Look at two candles. If the second one's high is lower than the first one's high, and its low is higher than the first one's low, the second candle is an inside bar. The first candle is called the mother bar. Nothing about the inside bar's colour or body matters, only its range.

An inside bar shows a moment of balance. Neither buyers nor sellers could push past the previous candle's range. Balance doesn't last, and when the price breaks out of the mother bar, traders take it as a sign of which side won. In Japanese candlestick terms the closest relative is the harami, but a harami compares bodies; the inside bar compares the whole range, wicks included. The candlestick patterns guide covers the harami.

Where traders look for inside bars

The rules, step by step

1. Spot the inside bar at its close

The candle's high is below the mother bar's high and its low is above the mother bar's low. The mother bar must be at least half the 14-period ATR tall, so tiny ranges don't count.

2. Place a stop order beyond the mother bar

In an uptrend (price above the 200 EMA), place a buy stop just above the mother bar's high: a twentieth of the ATR above it. You only get filled if the price breaks out. With the trend filter off, place a sell stop below the mother bar's low too; whichever fills first cancels the other.

3. Stop beyond the other side

The stop goes just below the mother bar's low. A tighter choice in the script is the inside bar's low, which gives a smaller stop and a bigger position but gets hit more often.

4. Target 2R, and cancel stale orders

The target is twice the risk. If the order hasn't filled within 3 candles, it's cancelled. If another inside bar forms first, the orders move to the new, smaller range.

Worked example: EURUSD, 4-hour chart

Mother barTarget 1.1836Buy stop 1.1726Stop 1.1671Inside barOrder fills2R
Illustrative chart drawn for this guide to show the rules. It isn't a real day's prices. EURUSD, 4-hour candles. The 200 EMA is left out to keep it readable.

EURUSD is in an uptrend. A strong 4-hour candle runs from 1.1672 to 1.1725, a 53-pip mother bar. The next candle stays inside it, between 1.1689 and 1.1717. With the price above the 200 EMA, a buy stop goes at 1.1726, just above the mother bar's high, and the next candle triggers it.

EURUSD long
Entry (buy stop)1.1726
Stop loss (below the mother bar)1.1671, 55 pips away
Target (2R)1.1836, 110 pips away
Account and risk$10,000, risking 1% = $100
Lot size$100 ÷ (55 pips × $10) = 0.18 lots
Loss if the stop is hit$99.00
Profit at the target$198.00

The breakout carries on and the target is reached 13 candles after the fill, a little over two days on the 4-hour chart. With the inside bar's low as the stop instead, the risk would have been about 38 pips and the position about 0.26 lots.

Risk management

Common mistakes

  1. Mixing up definitions. This script needs the inside bar's high strictly below the mother bar's high and its low strictly above; some traders count equal highs or lows, so pick one rule and keep it.
  2. Trading inside bars on tiny timeframes. On the 1- and 5-minute charts they're mostly noise.
  3. Entering at the inside bar's close. The idea is to wait for the breakout; the stop order does that.
  4. Ignoring the trend. A breakout against the trend is a reversal trade, and a harder one.

Related breakout ideas: the London breakout trades out of an overnight range, and the break and retest waits for a pullback after the break.

Backtest it yourself on TradingView

This page doesn't quote a win rate or a profit figure, and you should be wary of anyone who does without showing the test. Results change with the market, the dates, the data feed and the costs you put in. The honest way is to run the test yourself, and the free script below does the work in a couple of minutes.

  1. Open the chart. On TradingView, open EURUSD on the 4-hour chart.
  2. Add the script. Open the Pine Editor from the Pine icon in the panel on the right of the chart (older layouts have it as a tab under the chart), delete the code that's already there, paste this strategy's code and click "Add to chart".
  3. Put in your costs. Open the strategy's settings and go to Properties. Enter your broker's commission and a little slippage. A test without costs flatters every strategy, and short-term ones most of all.
  4. Read the Strategy Tester. The panel under the chart shows the net profit, the maximum drawdown, the profit factor, the number of trades and a list of every trade. Click a few trades and check on the chart that each one follows the rules. Trade sizes are shown in units rather than lots: 100,000 units is one lot of a forex pair, and 100 ounces is one lot of gold.
  5. Change one setting at a time. Compare the mother-bar stop with the inside-bar stop, the trend filter on and off (off places both orders), the minimum mother bar size and the 3-candle expiry. Try the daily chart and GBPUSD and XAUUSD too.

As a rough guide, don't trust a result with fewer than 100 trades, a profit factor under 1 once costs are in, or a drawdown you couldn't sit through with real money. Settings tuned to look good on one stretch of history often fail on the next, so check the same settings on dates you didn't tune them on, then demo trade the strategy for a few weeks. How much history you can test depends on your TradingView plan: the free plan loads 5,000 candles, which is a few months of 15-minute candles but years of daily ones.

The script sizes each trade from the stop loss and your risk percentage, starts with $10,000 and assumes 1:100 leverage (a 1% margin setting), so the tester doesn't flag margin calls on normal forex trade sizes. Change these under Properties to match your account. By default TradingView fills orders at the open of the candle after the signal, so the fill can differ a little from the signal candle's close. Stop orders fill at your stop price, or worse if a candle opens beyond it.

Download the free Pine Script and PDF

The script is written in Pine Script version 6 for this guide and follows the rules above. It can't read the economic calendar, so skipping news days is up to you. It's free to use, change and share. The PDF is a one-page cheat sheet with the rules, a worked example, the lot size maths and a checklist, to keep next to your chart.

Show the code (Pine Script v6, 72 lines)
//@version=6
// Inside Bar breakout strategy by PipLedger (https://pipledgerfx.com/inside-bar-strategy)
// When a candle trades inside the range of the one before it (the mother bar), places a stop order just beyond the mother bar.
// Free to use and change. For education and backtesting only; not financial advice.
strategy("PipLedger: Inside Bar Breakout", shorttitle="Inside Bar", overlay=true, initial_capital=10000, pyramiding=0, default_qty_type=strategy.fixed, default_qty_value=1, margin_long=1, margin_short=1, currency=currency.USD)

// ---------- Inputs
useTrend  = input.bool(true, "Only trade in the direction of the 200 EMA (off = both sides, one cancels the other)")
stopAt    = input.string("Mother bar", "Stop loss beyond", options=["Mother bar", "Inside bar"])
bufAtr    = input.float(0.05, "Buffer beyond the mother bar for the entry (x ATR 14)", minval=0.0, step=0.01)
validBars = input.int(3, "Candles the entry order stays open", minval=1)
minMother = input.float(0.5, "Mother bar at least (x ATR 14)", minval=0.0, step=0.1)
rr        = input.float(2.0, "Target (R multiple)", minval=0.5, step=0.25)
riskPct   = input.float(1.0, "Risk per trade (% of equity)", minval=0.1, maxval=5.0, step=0.1)

// ---------- Helpers
fx = strategy.convert_to_account(1.0)  // one unit of the chart's quote currency in account currency (1 on USD-quoted charts)
calcQty(float entry, float stop) =>
    float dist = math.abs(entry - stop)
    dist > 0 and not na(fx) ? strategy.equity * riskPct / 100 / (dist * syminfo.pointvalue * fx) : 0.0

atr    = ta.atr(14)
ema200 = ta.ema(close, 200)
inside = high < high[1] and low > low[1] and high[1] - low[1] >= minMother * atr[1]

var int   pend  = 0     // 1 = waiting orders are live
var int   pBar  = na
var float mHi   = na
var float mLo   = na

flat = strategy.position_size == 0
// a trade has opened, or the orders have waited long enough: cancel what's left
if pend == 1 and (not flat or (bar_index - pBar >= validBars and not inside))
    strategy.cancel("Long")
    strategy.cancel("Short")
    pend := 0

// ---------- New inside bar: stop orders beyond the mother bar
if flat and inside
    float buf    = atr * bufAtr
    float bEntry = high[1] + buf
    float sEntry = low[1] - buf
    float bSl    = (stopAt == "Mother bar" ? low[1] : low) - buf
    float sSl    = (stopAt == "Mother bar" ? high[1] : high) + buf
    bool  goL    = not useTrend or close > ema200
    bool  goS    = not useTrend or close < ema200
    float qL = calcQty(bEntry, bSl)
    float qS = calcQty(sEntry, sSl)
    pend := 0
    // a second inside bar moves the orders to the new, smaller mother bar (calling strategy.entry again with the same id updates the order)
    if goL and qL > 0
        strategy.entry("Long", strategy.long, qty=qL, stop=bEntry, oca_name="inside", oca_type=strategy.oca.cancel)
        strategy.exit("Long exit", "Long", stop=bSl, limit=bEntry + (bEntry - bSl) * rr)
        pend := 1
    else
        strategy.cancel("Long")
    if goS and qS > 0
        strategy.entry("Short", strategy.short, qty=qS, stop=sEntry, oca_name="inside", oca_type=strategy.oca.cancel)
        strategy.exit("Short exit", "Short", stop=sSl, limit=sEntry - (sSl - sEntry) * rr)
        pend := 1
    else
        strategy.cancel("Short")
    if pend == 1
        mHi  := high[1]
        mLo  := low[1]
        pBar := bar_index

// ---------- Chart
plot(pend == 1 ? mHi : na, "Mother bar high", color=color.new(color.teal, 0), style=plot.style_linebr)
plot(pend == 1 ? mLo : na, "Mother bar low", color=color.new(color.red, 0), style=plot.style_linebr)
plot(useTrend ? ema200 : na, "200 EMA", color=color.new(color.gray, 0))
plotshape(inside, "Inside bar", shape.circle, location.abovebar, color.new(color.orange, 0), size=size.tiny)

Trading this from India

Residents can trade EURUSD, GBPUSD and USDJPY futures and options on NSE and BSE through a SEBI-registered broker. The contracts are quoted the same way as the spot pair, one lot is 1,000 units of the base currency, and they're cash-settled in rupees. They trade only from 9 a.m. to 7:30 p.m. IST, volumes are thin and not every broker offers them, so check the hours and the spread first. Trading forex or CFDs with offshore online platforms isn't allowed for residents under FEMA, even if the app is easy to download. Details are in is forex trading legal in India.

Related strategies: break and retest, engulfing candle, previous day high and low, liquidity sweep, XAUUSD pin bar, support and resistance bounce. All 34 strategies are compared on one page in forex trading strategies.

Quick answers

What is an inside bar in trading?

A candle whose high is below the previous candle's high and whose low is above the previous candle's low, so its whole range sits inside the previous one. The previous candle is called the mother bar.

How do you trade an inside bar?

Place a buy stop just above the mother bar's high (or a sell stop below its low), with the stop on the other side of the mother bar and a target such as twice the risk. Many traders only take the side that matches the trend.

What is the difference between an inside bar and a harami?

Both show a small candle inside a bigger one. A harami compares the candle bodies; an inside bar compares the full ranges, including the wicks.

Which timeframe is best for inside bars?

Inside bars are most often traded on the 4-hour and daily charts, where each candle covers enough time to mean something. On very short timeframes they're very common and less reliable.

Where should the stop loss go on an inside bar trade?

Usually just beyond the other side of the mother bar. A tighter option is beyond the inside bar, which gets hit more often. The script has both.

What if two inside bars form in a row?

If the next candle is inside the first inside bar, and that bar is at least half the ATR tall, the script moves the orders to the smaller range. Otherwise they stay on the original mother bar until they fill or expire.

More guides

All 75 guides →

हिंदी में पढ़ें: Lot size kaise nikale?, Prop firm challenge kaise pass kare?, Gold trading kaise kare?, Forex trading kya hai, और India में यह legal है या नहीं?

Trading psychology

The habits that decide whether a good strategy makes money.

All 14 trading psychology guides

8 popular prop firms

Well-known firms for forex, gold and index traders that were still operating in 2026. Compare their rules before you buy a challenge.

If a link in this list is a referral link, PipLedger may earn a commission if you sign up, at no extra cost to you. This list is not a recommendation. Programs, prices and rules change often, so check each firm's own site, including its margin and drawdown rules, before you buy a challenge.