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

Opening range breakout (ORB) strategy for Nifty, with a free Pine Script

The opening range breakout, or ORB, is one of the simplest intraday strategies: mark the high and low of the first few minutes of the session, then trade the first decisive move out of that range. This guide gives rules for the Nifty 50 with the 9:15 to 9:30 a.m. range, a worked futures example with the lot size, settings for gold, and a free TradingView script to backtest it.

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

The rules at a glance

  • Market: Nifty 50 futures on the 5-minute chart (the settings can be changed for gold or forex)
  • Opening range: the high and low of the first 15 minutes, 9:15 to 9:30 a.m. IST
  • Entry: the first 5-minute candle between 9:30 a.m. and 1 p.m. that closes above the range high (long) or below the range low (short)
  • Stop loss: the other side of the range, or its middle
  • Target: twice the risk (2R); anything still open is closed at 3:15 p.m.
  • Skip the day: if the opening range is wider than 0.6 × the daily ATR; one trade a day

What an opening range breakout is

The first minutes after the market opens are busy. Overnight news, orders placed before the open and the reactions to both all hit the market at once, and the price swings while it finds its level. The high and low of those first minutes, the opening range, show where that early tug of war settled. A candle that later closes outside the range says one side has won, at least for now, and the ORB trades in that direction.

Trader Toby Crabel wrote about opening range breakouts in his 1990 book on short-term price patterns, and the idea has been used on stocks, index futures and currencies ever since. It's popular with Indian index traders because the Nifty's open at 9:15 a.m. is a clear, fixed starting point.

The rules, step by step

1. Mark the 9:15 to 9:30 range

On a 5-minute chart of Nifty futures, take the highest high and lowest low of the first three candles (9:15, 9:20 and 9:25). The market opens at 9:15 a.m. after a short pre-open session from 9:00, so the first candle already reflects the pre-open price.

2. Check the size of the range

Skip the day if the range is wider than 0.6 × the Nifty's average daily range (its 14-day ATR). A huge opening range means a big move has already happened, and the stop on the other side would be very far away. If the daily ATR is about 200 points, for example, the limit is 120 points.

3. Trade the first close outside the range

Between 9:30 a.m. and 1 p.m., go long when a 5-minute candle closes above the range high, or short when one closes below the range low. Only the first breakout of the day counts.

4. Stop on the other side, target 2R

The stop goes at the other side of the range: the range low for a long. The script can use the middle of the range instead, which cuts the risk by close to half and gets hit more often. The target is twice the risk.

5. Out by 3:15 p.m.

This is an intraday strategy, so anything still open at 3:15 p.m. is closed. Many brokers close intraday (MIS) positions automatically near the end of the session anyway; check your broker's time.

Worked example: Nifty 50 futures, 5-minute chart

Opening range9:30Target 25,285.50Entry 25,156.50Stop 25,092.00Close above the range2R
Illustrative chart drawn for this guide to show the rules. It isn't a real day's prices. Nifty 50 futures, 5-minute candles. The prices are examples, not a real session.

The first 15 minutes make a range from 25,092.00 to 25,148.00, 56 points. Say the daily ATR is about 200 points: the limit is 120, so this range passes. The 9:30 candle stays inside the range, and the 9:35 candle closes at 25,156.50, above the high. That's the long signal.

Nifty futures have traded in lots of 65 units since January 2026. NSE reviews lot sizes twice a year, so check the current size before you trade. Costs (brokerage, STT, exchange charges, GST) are left out.
Nifty futures long
Entry25,156.50
Stop loss (range low)25,092.00, 64.5 points away
Target (2R)25,285.50, 129 points away
Account and risk₹5,00,000, risking 1% = ₹5,000
Risk per lot64.5 points × 65 units = ₹4,192.50
Lots₹5,000 ÷ ₹4,192.50 = 1.19, so 1 lot
Loss if the stop is hit₹4,192.50
Profit at the target129 × 65 = ₹8,385

In this example the target is reached at 11:15 a.m., about an hour and a half after the entry. Many days don't work out that way: the price breaks the range, comes back inside and hits the stop, or drifts until the 3:15 p.m. exit. Because futures come in whole lots, the actual risk here is ₹4,192.50, about ₹808 under the ₹5,000 budget. With a smaller account, even one lot can be more risk than you planned, which is the main thing to check before trading index futures.

Another intraday Nifty futures setup is the VWAP pullback strategy, which trades dips to the day's average price.

ORB on gold and forex

The same rules work on any market with a clear session start. For gold, the London open is the usual choice. Change these settings in the script:

SettingNifty (default)Gold, London open
Time zoneAsia/KolkataEurope/London
Opening range09:15 to 09:3008:00 to 08:15
Breakout window09:30 to 13:0008:15 to 12:00
Trading day ends15:1516:00
Round to whole lots of650 (no rounding)
Margin (Properties and the margin input)12%1% (1:100 leverage)
Capital and currency (Properties)₹5,00,000, INR$10,000, USD

For example, if gold's range from 8:00 to 8:15 London time is 4,301.20 to 4,308.60 and a later candle closes at 4,310.10, the stop at the range low is $8.90 away. At $10,000 and 1% risk, that's $100 ÷ ($8.90 × 100 ounces) = 0.11 lots, with a 2R target at 4,327.90. The gold lot size calculator does this for any stop. In India, gold is traded legally on MCX rather than as a CFD; see XAUUSD market timings in India.

On forex pairs, the London breakout is the session version of the same idea, built on the whole overnight range instead of the first 15 minutes.

Prefer options to futures? The Nifty option payoff calculator shows what a spread or strangle pays at expiry, and the option selling guide covers the risks.

Risk management for Nifty ORB

Common mistakes

  1. Entering on the first tick above the range. Wait for the 5-minute candle to close.
  2. Trading the second breakout after the first fails. That doubles the day's risk. Test it separately if you want it.
  3. Using the spot chart's prices for futures orders. Futures trade at a premium or discount to the index. Use the futures chart for levels.
  4. Ignoring the range size. On gap days the opening range can be huge; the size check is there for those.
  5. Holding into the close to "give it time". The idea is about the morning's direction. By the afternoon it's a different trade.

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 NSE:NIFTY1! (Nifty futures, continuous contract; not NSEIX:NIFTY1!, which is GIFT Nifty) on the 5-minute 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: on Nifty futures, 65 units is one lot.
  5. Change one setting at a time. Compare the full-range stop with the mid-range stop, the 2R target with 1.5R, and the breakout window ending at 11 a.m. versus 1 p.m. Then try a 30-minute range (9:15 to 9:45). Test Bank Nifty separately and set its lot size (30 units since January 2026) in the script.

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, rounds it down to whole lots of 65 units, and starts with ₹5,00,000 at a 12% margin setting. It also caps any trade at 90% of the account as margin. Change the capital and margin under Properties, and the matching margin input in the script's settings, to suit your broker. 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. With one trade a day at most, 100 trades needs well over 100 sessions, and the free plan loads about 66 sessions of 5-minute Nifty candles, so you may need a paid plan's longer history.

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, the times, a worked example in rupees and a checklist, to keep next to your chart.

Show the code (Pine Script v6, 78 lines)
//@version=6
// Opening Range Breakout (ORB) strategy by PipLedger (https://pipledgerfx.com/opening-range-breakout-strategy)
// Marks the high and low of the first minutes after the open, then trades the first candle that closes outside them.
// Default settings are for Nifty 50 futures (9:15 to 9:30 a.m. IST). For gold, see the settings in the guide.
// Free to use and change. For education and backtesting only; not financial advice.
strategy("PipLedger: Opening Range Breakout", shorttitle="ORB", overlay=true, initial_capital=500000, pyramiding=0, default_qty_type=strategy.fixed, default_qty_value=1, margin_long=12, margin_short=12, currency=currency.INR)

// ---------- Inputs
tz        = input.string("Asia/Kolkata", "Time zone")
orSess    = input.session("0915-0930", "Opening range")
tradeSess = input.session("0930-1300", "Breakout window")
daySess   = input.session("0915-1515", "Trading day (open trades are closed at its end)")
stopMode  = input.string("Other side of the range", "Stop loss at", options=["Other side of the range", "Middle of the range"])
rr        = input.float(2.0, "Target (R multiple)", minval=0.5, step=0.25)
maxOrAtr  = input.float(0.6, "Skip if the range is wider than (x daily ATR 14)", minval=0.1, step=0.05)
riskPct   = input.float(1.0, "Risk per trade (% of equity)", minval=0.1, maxval=5.0, step=0.1)
marginPct = input.float(12, "Margin % (set the same under Properties)", minval=0.1, step=0.5)
qtyStep   = input.float(65, "Round quantity down to whole lots of (units; 0 = no rounding)", minval=0.0)

// ---------- Helpers
fx = strategy.convert_to_account(1.0)  // one unit of the chart's currency in account currency (1 on rupee charts)
calcQty(float entry, float stop) =>
    float dist = math.abs(entry - stop)
    float q = dist > 0 and not na(fx) ? strategy.equity * riskPct / 100 / (dist * syminfo.pointvalue * fx) : 0.0
    float qMax = entry > 0 and not na(fx) ? strategy.equity * 0.9 / (entry * syminfo.pointvalue * fx * marginPct / 100) : 0.0
    q := math.min(q, qMax)  // never more than 90% of the account as margin
    qtyStep > 0 ? math.floor(q / qtyStep) * qtyStep : q

dAtr    = request.security(syminfo.tickerid, "D", ta.atr(14)[1], lookahead=barmerge.lookahead_on)
inOr    = not na(time(timeframe.period, orSess, tz))
inTrade = not na(time(timeframe.period, tradeSess, tz))
inDay   = not na(time(timeframe.period, daySess, tz))
dayEnd  = timestamp(tz, year(time, tz), month(time, tz), dayofmonth(time, tz), int(str.tonumber(str.substring(daySess, 5, 7))), int(str.tonumber(str.substring(daySess, 7, 9))))

// ---------- Opening range
var float oHi  = na
var float oLo  = na
var bool  done = false
if inOr and not inOr[1]
    oHi  := high
    oLo  := low
    done := false
else if inOr
    oHi := math.max(oHi, high)
    oLo := math.min(oLo, low)

rangeOk  = not na(oHi) and not na(dAtr) and oHi - oLo <= maxOrAtr * dAtr
canTrade = inTrade and not inOr and not done and strategy.position_size == 0 and rangeOk and time_close < dayEnd
longSig  = canTrade and close > oHi
shortSig = canTrade and close < oLo
mid      = (oHi + oLo) / 2

// ---------- Orders (first breakout of the day only)
if longSig
    float sl = stopMode == "Other side of the range" ? oLo : mid
    float q  = calcQty(close, sl)
    done := true
    if q > 0
        strategy.entry("Long", strategy.long, qty=q)
        strategy.exit("Long exit", "Long", stop=sl, limit=close + (close - sl) * rr)
if shortSig
    float sl = stopMode == "Other side of the range" ? oHi : mid
    float q  = calcQty(close, sl)
    done := true
    if q > 0
        strategy.entry("Short", strategy.short, qty=q)
        strategy.exit("Short exit", "Short", stop=sl, limit=close - (sl - close) * rr)

// the candle that closes at the end of the trading day sends the order, so it fills then
if strategy.position_size != 0 and (time_close >= dayEnd or not inDay)
    strategy.close_all(comment="Day end")

// ---------- Chart
plot(oHi, "Range high", color=color.new(color.teal, 0), linewidth=2, style=plot.style_linebr)
plot(oLo, "Range low", color=color.new(color.orange, 0), linewidth=2, style=plot.style_linebr)
bgcolor(inOr ? color.new(color.gray, 88) : na, title="Opening range")
plotshape(longSig, "Long breakout", shape.triangleup, location.belowbar, color.teal, size=size.small)
plotshape(shortSig, "Short breakout", shape.triangledown, location.abovebar, color.red, size=size.small)

Trading this from India

Nifty futures and options are traded legally on NSE through a SEBI-registered broker. The rules on this page are for education and backtesting; they don't say what the market will do on any particular day. SEBI has tightened the rules for index derivatives since 2024, including bigger contract sizes and limits on weekly expiries, so check your broker's current margin, lot size and timing rules before you trade. More on the legal side is in is forex trading legal in India and algo trading in India.

Related strategies: London breakout, ICT kill zones, previous day high and low, XAUUSD London session, XAUUSD New York session, Nifty option selling, short strangle. All 34 strategies are compared on one page in forex trading strategies.

Quick answers

What is the opening range breakout strategy?

It marks the high and low of the first few minutes of the session, then trades the first candle that closes above the high (long) or below the low (short), with the stop on the other side of the range.

What is the best opening range time for Nifty?

There isn't one best time. The first 15 minutes (9:15 to 9:30 a.m.) is the most common; some traders use 5 or 30 minutes. A shorter range gives earlier, tighter but noisier trades. The script lets you test each.

Does ORB work for Nifty options?

The signals can come from the Nifty futures chart, and some traders then buy options instead of futures. Options add time decay and price swings in the premium, so the rupee result won't match the futures backtest. Test the exact instrument you'll trade.

What is the Nifty futures lot size?

Nifty futures have traded in lots of 65 units since January 2026. NSE reviews index lot sizes twice a year, so check the current size on NSE's site or your broker's app.

What stop loss should I use for ORB?

The usual stop is the other side of the opening range. The middle of the range cuts the risk by close to half but gets hit more often. Whichever you use, size the trade so the stop risks a fixed share of your account.

Can I use ORB for gold?

Yes. Use the London open (8:00 to 8:15 a.m. London time) or another session start as the range, set the time zone to Europe/London, and turn off lot rounding. The settings are in the table on this page.

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.