OPEN-SOURCE SCRIPT
Opening Range Gravity System

Opening Range Gravity System
What This Script Does
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
This indicator automatically detects the Opening Range formed during the first configurable minutes of the trading session and uses it as a gravitational anchor for the entire day. The opening range is where the largest institutional orders execute and the first price discovery battle takes place. Once the range is formed, price tends to gravitate toward its levels, break out from them, and target natural extensions beyond them.
The script locks the opening range at the end of the configured period with no repainting. Only the current day's range and signals are displayed. Previous days are automatically cleared when a new session begins.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
How It Works — 5 Components
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Opening Range High and Low
Formed during the first N minutes of session (user-configurable). Default is 15 minutes which works for both NSE India (9:15 to 9:30) and NYSE/Nasdaq (9:30 to 9:45). Displayed as solid yellow lines extending through the session.
● Opening Range Midpoint
The exact center of the opening range. Acts as the strongest intraday support and resistance level. Price frequently returns to this level after a breakout before continuing. Displayed as a white dashed line.
● Extension Targets (1x, 1.5x, 2x, 2.5x)
The opening range projected upward from the high and downward from the low at multiple distances. These are natural gravitational targets where price tends to slow, pause, or reverse. Displayed as dotted lines color-coded by direction.
● Breakout Signals
When price first closes above the opening range high, a bull breakout is marked. When price first closes below the opening range low, a bear breakout is marked. Each fires only once per session.
● Trap and Midpoint Bounce Detection
If price breaks the opening range but closes back inside within a configurable window, a trap signal is drawn. If price pulls back to the midpoint after a breakout and bounces, a midpoint bounce signal is drawn. These are educational observations about market structure, not buy or sell signals.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Visual Elements on Chart
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Yellow zone box — opening range period highlighted
● Yellow candles — candles formed inside the opening range period
● Yellow solid lines — OR High and OR Low extending through session
● White dashed line — OR Midpoint
● Teal dotted lines — upside extension targets (1x, 1.5x, 2x, 2.5x)
● Red dotted lines — downside extension targets
● Teal label — bull breakout signal
● Red label — bear breakout signal
● Orange label — trap signal (failed breakout)
● White label — midpoint bounce signal
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Dashboard
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Price vs OR — shows whether price is above OR high, below OR low, above midpoint, or below midpoint
● Last Signal — most recent signal type for the session
● OR High, Low, and Midpoint — exact levels in price
● OR Range — total opening range in points
● 1x Target Up and Down — first extension targets above and below
● Bull and Bear Breakout counts — per session
● Traps Detected and Mid Bounces — per session
Dashboard position is fully movable from settings. No code editing required.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
How to Use — Step by Step
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Step 1 — Set OR Duration to match your market
For NSE India use 15. For NYSE or Nasdaq use 15 or 30. Set the session time to match your exchange open.
● Step 2 — Wait for the opening range to lock
Yellow zone and lines appear automatically after the OR period ends. The dashboard will show exact High, Low, and Midpoint values.
● Step 3 — Watch for breakout labels
When BO BULL or BO BEAR appears, note the direction. Check whether volume and context support the move.
● Step 4 — Watch for trap signals
Orange BULL TRAP or BEAR TRAP label means the breakout failed. This is often a high-probability reversal observation in the opposite direction.
● Step 5 — Watch extension targets
Use the 1x dotted line as the first reference target. The 1.5x and 2x lines are secondary reference levels for the session.
● Step 6 — Midpoint is the day's anchor
If price is above the midpoint and holds it, the session has a bullish character. If price is below the midpoint, the session has a bearish character.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Recommended Settings
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Best timeframes — 5 minute or 15 minute for intraday observation
● OR Duration — 15 minutes for NSE, NYSE, Nasdaq
● Works on — Nifty, BankNifty, stocks, futures, crypto, forex, any liquid instrument
● Alerts available — OR Breakout, Trap Detection, Midpoint Test
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Technical Details
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● No repainting — opening range locks at end of OR period and does not change
● No lookahead bias — all calculations use confirmed bar data only
● No external data — built entirely on price
● Pine Script v6 — written on the latest version
● Session-based reset — all drawings and signals reset automatically each new day
● Original code — not derived from any existing published script
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Disclaimer
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
This script is published for educational and informational purposes only. It does not generate buy or sell signals. It does not guarantee any trading results. Past behavior of price at opening range levels does not guarantee future results. The author is not responsible for any financial losses incurred from use of this tool. Always conduct your own research and consult a licensed financial professional before making any trading decisions.
What This Script Does
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
This indicator automatically detects the Opening Range formed during the first configurable minutes of the trading session and uses it as a gravitational anchor for the entire day. The opening range is where the largest institutional orders execute and the first price discovery battle takes place. Once the range is formed, price tends to gravitate toward its levels, break out from them, and target natural extensions beyond them.
The script locks the opening range at the end of the configured period with no repainting. Only the current day's range and signals are displayed. Previous days are automatically cleared when a new session begins.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
How It Works — 5 Components
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Opening Range High and Low
Formed during the first N minutes of session (user-configurable). Default is 15 minutes which works for both NSE India (9:15 to 9:30) and NYSE/Nasdaq (9:30 to 9:45). Displayed as solid yellow lines extending through the session.
● Opening Range Midpoint
The exact center of the opening range. Acts as the strongest intraday support and resistance level. Price frequently returns to this level after a breakout before continuing. Displayed as a white dashed line.
● Extension Targets (1x, 1.5x, 2x, 2.5x)
The opening range projected upward from the high and downward from the low at multiple distances. These are natural gravitational targets where price tends to slow, pause, or reverse. Displayed as dotted lines color-coded by direction.
● Breakout Signals
When price first closes above the opening range high, a bull breakout is marked. When price first closes below the opening range low, a bear breakout is marked. Each fires only once per session.
● Trap and Midpoint Bounce Detection
If price breaks the opening range but closes back inside within a configurable window, a trap signal is drawn. If price pulls back to the midpoint after a breakout and bounces, a midpoint bounce signal is drawn. These are educational observations about market structure, not buy or sell signals.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Visual Elements on Chart
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Yellow zone box — opening range period highlighted
● Yellow candles — candles formed inside the opening range period
● Yellow solid lines — OR High and OR Low extending through session
● White dashed line — OR Midpoint
● Teal dotted lines — upside extension targets (1x, 1.5x, 2x, 2.5x)
● Red dotted lines — downside extension targets
● Teal label — bull breakout signal
● Red label — bear breakout signal
● Orange label — trap signal (failed breakout)
● White label — midpoint bounce signal
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Dashboard
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Price vs OR — shows whether price is above OR high, below OR low, above midpoint, or below midpoint
● Last Signal — most recent signal type for the session
● OR High, Low, and Midpoint — exact levels in price
● OR Range — total opening range in points
● 1x Target Up and Down — first extension targets above and below
● Bull and Bear Breakout counts — per session
● Traps Detected and Mid Bounces — per session
Dashboard position is fully movable from settings. No code editing required.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
How to Use — Step by Step
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Step 1 — Set OR Duration to match your market
For NSE India use 15. For NYSE or Nasdaq use 15 or 30. Set the session time to match your exchange open.
● Step 2 — Wait for the opening range to lock
Yellow zone and lines appear automatically after the OR period ends. The dashboard will show exact High, Low, and Midpoint values.
● Step 3 — Watch for breakout labels
When BO BULL or BO BEAR appears, note the direction. Check whether volume and context support the move.
● Step 4 — Watch for trap signals
Orange BULL TRAP or BEAR TRAP label means the breakout failed. This is often a high-probability reversal observation in the opposite direction.
● Step 5 — Watch extension targets
Use the 1x dotted line as the first reference target. The 1.5x and 2x lines are secondary reference levels for the session.
● Step 6 — Midpoint is the day's anchor
If price is above the midpoint and holds it, the session has a bullish character. If price is below the midpoint, the session has a bearish character.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Recommended Settings
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Best timeframes — 5 minute or 15 minute for intraday observation
● OR Duration — 15 minutes for NSE, NYSE, Nasdaq
● Works on — Nifty, BankNifty, stocks, futures, crypto, forex, any liquid instrument
● Alerts available — OR Breakout, Trap Detection, Midpoint Test
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Technical Details
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● No repainting — opening range locks at end of OR period and does not change
● No lookahead bias — all calculations use confirmed bar data only
● No external data — built entirely on price
● Pine Script v6 — written on the latest version
● Session-based reset — all drawings and signals reset automatically each new day
● Original code — not derived from any existing published script
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Disclaimer
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
This script is published for educational and informational purposes only. It does not generate buy or sell signals. It does not guarantee any trading results. Past behavior of price at opening range levels does not guarantee future results. The author is not responsible for any financial losses incurred from use of this tool. Always conduct your own research and consult a licensed financial professional before making any trading decisions.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.