OPEN-SOURCE SCRIPT

Opening-Range Breakout

436
Note: Default trading date range looks mediocre. Set date range to "Entire History" to see full effect of the strategy. 50.91% profitable trades, 1.178 profit factor, steady profits and limited drawdown. Total P&L: $154,141.18, Max Drawdown: $18,624.36. High R^2

Overview

The Opening-Range Breakout strategy is a mechanical, session‑based day‑trading system designed to capture the initial burst of directional momentum immediately following the market open. It defines a user‑configurable “opening range” window, measures its high and low boundaries, then places breakout stop orders at those levels once the range closes. Built‑in filters on minimum range width, reward‑to‑risk ratios, and optional reversal logic help refine entries and manage risk dynamically.


How It Works

Opening‑Range Formation

Between 9:30–10:15 AM ET (configurable), the script tracks the highest high and lowest low to form the day’s opening range box.

On the first bar after the range window closes, the range high (OR_high) and low (OR_low) are “locked in.”

Range‑Width Filter

To avoid false breakouts in low‑volatility mornings, the range must be at least X% of the current price (default 0.35%).

If the measured opening-range width < minimum threshold, no orders are placed that day.

Entry & Order Placement

Long: a stop‑buy order at the opening‑range high.

Short: a stop‑sell order at the opening‑range low.

Only one side can trigger (or both if reverse logic is enabled after a losing trade).

Risk Management

Once triggered, each trade uses an ATR‑style stop-loss defined as a percentage retracement of the range (default 50% of range width).

Profit target is set at a configurable Reward/Risk Ratio (default 1.1×).

Optional: Reverse on Stop‑Loss – if the initial breakout loses, immediately reverse into the opposite side on the same day.

Session Exit

Any open positions are closed at the end of the regular trading day (default 3:45 PM ET window end, with hard flat at session close).

Visual cues are provided via green (range high) and red (range low) step‑line plots directly on the chart, allowing you to see the range box and breakout triggers in real time.


Why It Works

Early Momentum Capture: The first 15 – 60 minutes of trading encapsulate overnight news digestion and institutional order flow, creating a well‑defined volatility “range.”

Mechanical Discipline: Clear, rule‑based entries and exits remove emotional guesswork, ensuring consistency.

Volatility Filtering: By requiring a minimum range width, the system avoids choppy, low‑range days where false breakouts are common.

Dynamic Sizing: Stops and targets scale with the opening range, adapting automatically to each day’s volatility environment.

How to Use

Set Your Instruments & Timeframe

-Apply to any futures contract on a 1‑ to 5‑minute chart.

-Ensure chart timezone is set to America/New_York.

Configure Inputs

-Opening‑Range Window: e.g. “0930-1015” for a 45‑minute range.

-Min. OR Width (%): e.g. 0.35 for 0.35% of current price.

-Reward/Risk Ratio: e.g. 1.1 for a modest profit target above your stop.

-Max OR Retracement %: e.g. 50 to set stop at 50% of range width.

-One Trade Per Day: toggle to limit to a single breakout.

-Reverse on Stop Loss: toggle to flip direction after a losing breakout.

Monitor the Chart

-Watch the green and red range boundaries form during the session open.

-Orders will automatically submit on the first bar after the range window closes, conditioned on your filters.

Review & Adjust

-Backtest across multiple months to validate performance on your preferred contract.

-Tweak range duration, minimum width, and R/R multiple to fit your risk tolerance and desired win‑rate vs. expectancy balance.

Settings Reference

Input Defaults
Opening‑Range Window - Time window to form OR (HHMM-HHMM) - 0930–1015
Regular Trading Day - Full session for EOD flat (HHMM-HHMM) - 0930–1545
Min. OR Width (%) - Minimum OR size as % of close to trigger orders - 0.35
Reward/Risk Ratio - Profit target multiple of stop‑loss distance - 1.1
Max OR Retracement (%) - % of OR width to use as stop‑loss distance - 50
One Trade Per Day - Limit to a single breakout order per day - false
Reverse on Stop Loss - Reverse direction immediately after a losing trade - true

Disclaimer
This strategy description and any accompanying code are provided for educational purposes only and do not constitute financial advice or a solicitation to trade. Futures trading involves substantial risk, including possible loss of capital. Past performance is not indicative of future results. Traders should assess their own risk tolerance and conduct thorough backtesting and forward-testing before committing real capital.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.