Strategy · Pine Script v5 · On the chart

Opening range breakout

by yawningmonsoon

This strategy builds an opening-range high and low during a user-defined session, then waits until that session ends.

View on GitHub

Repaints

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code15
Settings1inputs
LicenceMIT
Last update2 weeks ago12 Oct 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

15 lines of Pine Script v5 from examples/strategies/opening-range-breakout.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

opening-range-breakout.pine
//@version=5
// A textbook opening range breakout, written for this repo as a reading example (not a recommendation).
strategy("Opening range breakout", overlay=true, calc_on_every_tick=true)
sess = input.session("0930-0945", "Opening range")
inR = not na(time(timeframe.period, sess))
var float hi = na
var float lo = na
hi := inR ? math.max(nz(hi, high), high) : hi
lo := inR ? math.min(nz(lo, low), low) : lo
if not inR and close > hi
    strategy.entry("L", strategy.long)
if not inR and close < lo
    strategy.entry("S", strategy.short)
strategy.exit("xL", "L", stop=lo, limit=hi + (hi - lo))
strategy.exit("xS", "S", stop=hi, limit=lo - (hi - lo))

Overview

A close above the range enters long and a close below it enters short. The long exit uses the range low as the stop and a limit one range-width above the high; the short exit mirrors that with the range high as the stop. The session input changes which bars form the range. Signals are drawn on the price chart and can change on the live bar because the strategy calculates on every tick.

Details

Published by

yawningmonsoon on GitHub

Draws

On the price chart

Markets

Indices

Timeframes

M15-H1

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Topics

agentic-tradingai-agentsalgorithmic-tradingbacktestingclaudecryptofutureshallucinationllmmcp

Settings

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

SettingTypeDefaultVariable
Opening rangesession0930-0945sess
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
53 stars

This strategy enters long or short on the price chart when price is on the correct side of a 200-period EMA, MACD agrees, RSI is not at the opposing extreme, ADX exceeds a threshold, volume beats a 20-bar average, and close breaks the recent high or low. A tim

Strategy v6 TrendOscillators & momentum
Updated 2 months ago · MPL-2.0 GitHub repository of BTCUSD 5M Optimized Strategy

Turtle MACD Time-Zone Filter

by skywalker0803r
42 stars

This strategy enters long when price closes above the prior Donchian high and short when it closes below the prior Donchian low, only while flat and inside a Taipei-hour window. It exits on a MACD histogram reversal or through an ATR stop and a percentage take

Strategy v5 BreakoutOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Turtle MACD Time-Zone Filter
39 stars

This intraday strategy implements Mark Fisher's Opening Range Breakout (ORB) methodology tailored for index futures like ES and NQ. It calculates session opening ranges, volume z-scores, and VWAP bands to plot support, resistance, and confirmation levels on th

Strategy v6 BreakoutSessions & time Repaints
Updated 6 days ago · MIT GitHub repository of Futures Intraday Pro (ES/NQ) Strategy

Morning Scalp

by benso87
24 stars

This strategy tracks an opening session time range to establish directional bias and triggers pullback trades using Stochastic RSI. Once price breaks out of the initial range, it establishes a directional bias and enters when the Stochastic RSI crosses over in

Strategy v5 Sessions & timeBreakout
Updated 4 years ago · MPL-2.0 GitHub repository of Morning Scalp
23 stars

This strategy evaluates breakout and trend opportunities on the price chart using a weighted composite score of volume, trend, and candlestick structure. It tracks volume spikes, fast and slow EMAs, higher-timeframe EMA trend alignment, opening ranges, and ses

Strategy v6 TrendVolume Repaints
Updated 4 weeks ago · Custom licence GitHub repository of TradingAlpha Point-Clip Strategy

More Breakout scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers