Strategy · Pine Script v5 · On the chart

ORB Hooplah Strategy

by g-moe· code credited to goodgains

This strategy detects Opening Range Breakouts in a specified session.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code149
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 2026

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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

149 lines of Pine Script v5 from Tradingview/orb-hooplah-strategy.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

orb-hooplah-strategy.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
strategy("ORB_hooplah strategy", overlay=true, margin_long=100, margin_short=100, max_labels_count = 500)

// @keywords: opening-range, orb-breakout, orb-breakdown, range-high, range-low, strategy-entries, colored-candles, session-orb, profit-target, time-exit, yellow-bar-exit, breakout-labels, opening-range-box, range-fill, barssince-break, call-long, put-short, orb-session, max-bars-break, strategy-alerts

// inputs
_color_candles = input.bool(true, title = 'Color Candles', group = 'Settings', inline = '1')
_orb_session = input.session('0930-1000', title = 'ORB Session', group = 'Settings', inline = '2')
_max_bars_break = input.int(1, title = 'Max Bars Since Break', group = 'Settings', inline = '3')

_exit_yellow_bars = input.bool(true, title = 'Exit on Yellow Bars', group = 'Settings', inline = '4')
_exit_at_time = input.bool(true, title = 'Time Exit', group = 'Settings', inline = '5')
_time_to_exit = input.session('0930-1530', title = '', group = 'Settings', inline = '5')
_exit_tp = input.bool(false, title = 'Profit Target', group = 'Settings', inline = '6')
_tp_amount = input.float(50.00, title = '', group = 'Settings', inline = '6', step = 1)

// calculate orb
or_session = time(timeframe.period, str.format('{0}:1234567', _orb_session), 'America/New_York')
var or_high = 0.0
var or_low = 0.0
var or_mid = 0.0
var days_open = 0.0

var bool orh_break = na
var bool orl_break = na
var bool breakout_scan = na
var bool breakdown_scan = na

if or_session
    if not or_session[1]
        or_low := low
        or_high := high
        days_open := open
    else 
        or_low := math.min(low, or_low)
        or_high := math.max(high, or_high)
else if dayofweek != dayofweek[1]
    or_low := na
    or_high := na
    days_open := na


orh_break := ta.crossover(close, or_high)
orl_break := ta.crossunder(close, or_low)

breakout_scan := ta.barssince(orh_break) < _max_bars_break
breakdown_scan := ta.barssince(orl_break) < _max_bars_break



// visualize
or_high_plot = plot(not or_session ? or_high : na, title='ORH', 
 color=color.new(color.white, 0), linewidth=2, style=plot.style_linebr, offset = -1)
or_low_plot = plot(not or_session ? or_low : na, title='ORL', 
 color=color.new(color.white, 0), linewidth=2, style=plot.style_linebr, offset = -1)

fill(or_high_plot, or_low_plot, title='OR Fill', color=color.new(color.silver, 90))


orb_color = not _color_candles ? na 
 : not or_session and na(or_high) ? color.gray
 : or_session ? color.white
 : close > or_high ? color.lime
 : close < or_low ? color.red 
 : color.yellow


orb_side = not or_session and na(or_high) ? 100
 : or_session ? 99
 : close > or_high ? 1
 : close < or_low ? -1
 : 0

barcolor(orb_color)
plotcandle(open, high, low, close, title = 'Custom Candles',
 color = orb_color, wickcolor = orb_color, bordercolor = orb_color)

var int last_buysellsignal = 0
var bool buy_signal = na
var bool sell_signal = na

// var float long_stop = 0.00
// var float short_stop = 0.00
var float long_tgt = 0.00
var float short_tgt = 0.00

buy_signal := barstate.isconfirmed and breakout_scan and (nz(last_buysellsignal[1],0) != 1)
sell_signal := barstate.isconfirmed and breakdown_scan and (nz(last_buysellsignal[1],0) != -1)
// last_buysellsignal := buy_signal ? 1 : sell_signal ? -1 : last_buysellsignal[1] 

long_tgt := buy_signal ? close + _tp_amount 
 : strategy.position_size > 0 ? strategy.position_avg_price + _tp_amount 
 : na

short_tgt := sell_signal ? close - _tp_amount
 : strategy.position_size < 0 ? strategy.position_avg_price - _tp_amount 
 : na

// alerts
if buy_signal
    alert("OR Breakout", alert.freq_once_per_bar_close)
    label.new(bar_index, low, text = 'CALL/LONG ' + str.tostring(close),
     color = color.green, textcolor = color.white, style = label.style_label_up)

if sell_signal
    alert("OR Breakdown", alert.freq_once_per_bar_close)
    label.new(bar_index, high, text = 'PUT/SHORT ' + str.tostring(close),
     color = color.red, textcolor = color.white, style = label.style_label_down)

trading_session = time(timeframe.period, str.format('{0}:1234567', _time_to_exit), 'America/New_York')
is_exit_time = not trading_session

long_exit = last_buysellsignal == 1 
 and ( (_exit_yellow_bars and orb_side == 0)
 or (_exit_at_time and is_exit_time)
 )

short_exit = last_buysellsignal == -1 
 and ( (_exit_yellow_bars and orb_side == 0)
  or (_exit_at_time and is_exit_time)
 )


last_buysellsignal := buy_signal ? 1 
 : sell_signal ? -1 
 : (long_exit or short_exit) ? 0 
 : last_buysellsignal[1]


// send orders
if buy_signal
    strategy.entry("LE", strategy.long)
if sell_signal
    strategy.entry("SS_E", strategy.short)

if long_exit 
    strategy.close("LE", "LX", immediately = true)
if short_exit 
    strategy.close("SS_E", "SS_X", immediately = true)


if _exit_tp
    strategy.exit("L_TP", from_entry = "LE", limit = long_tgt)
if _exit_tp
    strategy.exit("SS_TP", from_entry = "SS_E", limit = short_tgt)

Overview

ORB Hooplah Strategy calculates the high and low of the opening range bar then plots these levels on the price chart and fills the area between them. Candles are colored based on their relation to the ORB high and low. Long signals trigger on breakout above the OR high within the max bars since break while short signals occur on breakdown below the OR low. Exits happen on yellow bars, at a fixed time, or upon reaching the profit target. It draws breakout labels and uses custom candle coloring.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Breakout, Support & resistance, Sessions & time, Candlestick patterns

Markets

Forex, Indices

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Settings

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

SettingTypeDefaultVariable
Color Candlesbooltrue_color_candles
ORB Sessionsession0930-1000_orb_session
Max Bars Since Breakint1_max_bars_break
Exit on Yellow Barsbooltrue_exit_yellow_bars
Time Exitbooltrue_exit_at_time
_time_to_exitsession0930-1530_time_to_exit
Profit Targetboolfalse_exit_tp
_tp_amountfloat50.00_tp_amount
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

106 stars

This script monitors opening gap conditions and breakout behavior relative to the first candle's range across up to twenty configurable stock tickers. It detects whether following bars remain inside the opening range before breaking out, displaying the status

Strategy v4 Screeners & dashboardsBreakout Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 1St Bar GAP+BkOut Screener v2 by RM
7 stars

This overlay strategy tracks the high and low of a user-defined London session and plots the previous session levels as support and resistance. It flags a break beyond a level when price closes past an ATR buffer, then waits a set number of bars for a retest w

Strategy v5 Sessions & timeSupport & resistance
Updated 3 months ago · None stated GitHub repository of London SR Cleaner WR (TP 0.20)
6 stars

This strategy combines Opening Range Breakout (ORB) mechanics with Inner Circle Trader (ICT) concepts like Fair Value Gaps, Order Blocks, and liquidity grabs. It identifies session opening ranges and generates signals when price breaks out with supporting rela

Strategy v5 BreakoutSMC / ICT / price action
Updated 7 months ago · None stated GitHub repository of Advanced ORB + ICT Strategy

Dollar Cross Play

by majohnst
1 stars

The Dollar Cross Play strategy detects price breakouts above a user-defined dollar threshold. It qualifies long entries by verifying that the previous day's close was at or below a maximum ceiling, aiming to capture fresh crosses rather than overextended moves

Strategy v6 BreakoutSupport & resistance
Updated 3 months ago · None stated GitHub repository of Dollar Cross Play

ES Absolute Trigger

by knectardev
1 stars

This strategy captures the first bar of each new day as an opening range and plots those high and low levels on the price chart. It enters one long position if price trades above the range high, or one short if price trades below the range low, then blocks fur

Strategy v5 BreakoutSessions & time
Updated 9 months ago · None stated GitHub repository of ES Absolute Trigger

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers