OPEN-SOURCE SCRIPT
Atualizado Opening Range Breakout & Liquidity Engine

Opening Range Breakout & Liquidity Engine
Overview
A complete intraday opening-range-breakout engine. For each session it auto-detects the open, builds the opening range (the high–low band of the first N minutes, where the day's initial balance is set), and then does the three things most opening-range scripts leave out: it filters the day for tradability, it projects a trade map (targets and a stop) scaled to that day's own volatility, and it keeps an honest, on-chart win-rate tally of how often breaks actually reach their first target before the stop. It draws the structure and the map; it does not place orders. Analytical tool, not advice.
What makes it different — why these pieces are ONE engine (mashup rationale)
The opening range is the substrate — the reference band the whole day is measured against (ORH / ORL / midpoint).
The relative-volume ("in play") filter asks whether the range formed on above-average volume — the single biggest edge driver in the research. A break on a quiet day and a break on an active day are not the same event, so the engine measures the range's volume against a rolling average of prior sessions' opening-range volume and flags it.
The direction filter can require the break to agree with the opening-range candle's own direction, dropping the counter-range breaks that fare worst.
The accepted-break logic (close beyond the edge, optionally held a bar) separates a real initiative move from a wick.
The trade map projects targets (as range multiples or risk/R multiples) and a stop (opposite edge, range midpoint, or an ATR distance), so the plan scales to each day's volatility instead of fixed points — and reports the resulting R:R.
The win-rate harness closes the loop: it tracks every break until it tags target 1 or the stop and reports a real, path-aware Hit % and Edge on your instrument (optionally in-play only), logging unresolved breaks as end-of-day exits separately.
The failed-break module handles the other half of reality: a break that closes back inside the range traps breakout traders, so the engine flags it, projects the reversal to the opposite edge (stop at the failure extreme), and runs a second harness measuring how often that fade reaches the opposite edge before the failure is re-broken. A retest-hold flag marks the high-probability continuation entry; a trap flag marks both-edges-broken days; a range-state read (compressed / normal / wide) says what kind of break you're looking at.
Split apart, each piece is a fragment: a box without the filters is noise, targets without the harness are guesses, and a break with no failure case is half the picture. Chained, they answer one question — is this opening-range break worth taking here, and if it fails, is the fade? That interdependence is why it's a single engine, not a bundle.
What this adds over a standard opening-range script
Most ORB scripts stop at drawing the box and the two breakout lines. This engine adds the parts that decide and verify:
Relative-volume "in play" filter. Flags whether today's opening range formed on above-average volume — research-shown to be the dominant driver of opening-range edge — with an optional toggle to count only in-play days in the stats.
Range-direction filter. Optionally restricts breaks to the direction the opening-range candle closed, removing the weakest counter-range trades.
Volatility-scaled trade map. Targets as range or R (risk) multiples; stop at the opposite edge, the range midpoint, or an ATR distance — with the live R:R shown.
Path-aware win-rate harness. Tracks each break to target 1 or stop and reports an honest Hit % / Edge (vs a 50% coin-flip), counting end-of-day exits separately — a real, in-sample reality check, not a curve-fit claim.
Failed-break reversal module. Detects the break that closes back inside the range (a fakeout — research puts breakout failure rates in the 60–80% range), projects the fade toward the opposite edge with the failure extreme as its stop, and runs a second harness reporting how often the fade reaches that edge first. A failed break is often the better trade, and almost no ORB script measures it.
Retest-hold, trap and range-state context. A retest-hold flag marks the broken edge holding as support/resistance (the higher-probability continuation entry); a trap flag marks both-edges-broken whipsaw days; a range-state read (compressed / normal / wide vs the rolling average) says whether the break is likely to run or fail.
Reference levels with built-in legends. Current-day H/L, prior-day H/L (PDH/PDL) and prior-week H/L (PWH/PWL) — the most-watched intraday liquidity pools — are drawn as labelled lines that extend right, each tagged (DH/DL/PDH/PDL/PWH/PWL) so every line identifies itself. A Day position read shows whether price is above PDH, inside the prior-day range, or below PDL.
Liquidity-sweep detection, fused with the failure logic. A sweep — price wicks beyond PDH/PDL/PWH/PWL and closes back inside, taking the stops there — is flagged with a marker and in the dashboard. Because the opening-range edges are themselves prime liquidity, a failed ORB break that sweeps a level is the highest-conviction version of the fade; the engine ties the two together.
Institution-grade, readable visuals. Events are compact bar-anchored markers (triangle / cross / circle / flag) instead of stacked labels; key levels are drawn as glowing lines with bold colour-coded legend chips at the right edge; a legend-key panel decodes every mark and line; and only the most recent sessions' drawings are kept, so the chart stays clean even after months of history. The dashboard and legend key are theme-adaptive — they auto-match a light or dark chart background for proper contrast.
Auto-session that works where others break. New-session detection keys off a calendar-day change in the instrument's own timezone, so it resets correctly even on feeds with no out-of-session bars (NSE index futures only print 09:15–15:30) — where edge-detection scripts silently fail.
Fused decision dashboard. Break state, ORH/ORL, range, range state, range direction, relative volume / in-play, targets, stop, R:R, day position vs the prior day, liquidity-sweep status, the running Hit % / Edge, the failed-break fade and its Hit % / Edge, and retest/trap status — theme-adaptive to your chart.
How it works
Session: Auto groups by the instrument's trading day in its native timezone (works even with no out-of-session bars); Manual pins a window. Range: the high/low of the first N minutes become ORH/ORL; the midpoint is the pivot; the range candle's close-vs-open sets the range direction; its volume vs a rolling average gives the relative-volume "in play" read; its size vs a rolling average gives the range state (compressed / normal / wide). Break: the first close beyond ORH (long) or ORL (short) after the range completes, optionally held a bar and optionally restricted to the range direction. Map: targets = break edge + range multiples, or entry + risk (R) multiples; stop = opposite edge, range midpoint, or an ATR distance. Harness: each break is followed until it tags target 1 or the stop; unresolved breaks at the close are logged as end-of-day exits, separate from the Hit %. Failure: if an accepted break closes back inside the range it is flagged failed; the reversal targets the opposite edge with the failure extreme as stop, and a separate fade harness reports how often that reversal reaches the opposite edge before the failure extreme is re-broken. A retest of the broken edge that holds is flagged continuation; both edges breaking is flagged a trap. Levels: current-day H/L (tracked live), prior-day H/L and prior-week H/L (from the weekly series) are drawn as labelled lines (DH/DL, PDH/PDL, PWH/PWL) extending right. Liquidity: a sweep is a bar that wicks a set fraction of ATR beyond PDH/PDL/PWH/PWL then closes back inside — the stops there are taken and price rejects — flagged with a marker and in the dashboard alongside the day-position read.
How to use
Trade with an accepted break toward target 1 / 2, invalidated back inside the range (or at the chosen stop); favour in-play, range-direction and compressed-range breaks, and breaks that also clear PDH / PWH (genuine acceptance through liquidity) — all shown to carry the edge. When a break fails back inside, or sweeps a key level and rejects, the fade toward the opposite edge is often the better trade — the dashboard's fade Hit % / Edge tells you whether it has paid here. A retest that holds confirms continuation; a trap (both edges broken) is usually a stand-aside. Use the Hit % / Edge reads as a reality check before relying on any of it. Context for your decisions — not a standalone trigger.
Universal across markets (configurable data source)
High / low / close sources, the session mode / window / timezone and the range length are all inputs, so the engine runs on any instrument and intraday timeframe. Defaults target NSE NIFTY index futures with a first-15-minute range (the research tested 5 / 15 / 30 / 60 minutes; 5 was best on US single stocks). Change the sources, session and range for any other market. Use an intraday chart; the relative-volume filter needs a real volume feed and degrades gracefully without one.
Originality
The opening-range, fakeout-reversal and liquidity concepts are public (credited below); the original work is the assembly and the code — auto-session detection that works on instruments with no out-of-session bars, the relative-volume "in play" / range-direction / range-state filters, the range / R-multiple trade map with ATR stop and end-of-day exit, the path-aware win-rate harness, the failed-break reversal module with its own fade harness, and the reference-level + liquidity-sweep engine that ties the break to prior-day / prior-week liquidity. No third-party code is reused.
Companion drawings (TradingView compliance note)
Everything this plots is part of the one engine and is explained above — the opening-range box, the ORH/ORL/midpoint lines, the day/week reference levels (DH/DL, PDH/PDL, PWH/PWL) with their right-edge legends, the bar-anchored break / failed / retest / sweep markers, the target / stop / reversal lines, the legend-key panel, and the dashboard. There are no unrelated studies. Before publishing, clean the chart so only this indicator is shown.
Concept credit
The opening-range-breakout concept is long-standing market lore, formalised by Toby Crabel ("Day Trading with Short Term Price Patterns and Opening Range Breakout") and related to Mark B. Fisher's ACD method ("The Logical Trader"). The relative-volume "stocks in play" filter and the range-direction entry follow the empirical study of Zarattini, Barbon & Aziz (2023–24). The failed-breakout (fakeout) reversal and retest-hold continuation are classic price-action concepts, and prior-day / prior-week liquidity with the liquidity-sweep (stop-raid-then-reject) read are general price-action / Smart-Money-Concept ideas in wide public use. Implementation is original; not affiliated with, nor endorsed by, any third party, and no third-party code is reused.
Honesty / limitations
The Hit % is path-aware but in-sample, ignores costs and slippage, assumes the target/stop fills exactly at touch, and counts one break per session — descriptive context, not a verified backtest. Opening-range behaviour varies by instrument, session and regime. This engine maps structure; it does not predict which breaks will work.
Disclaimer
Research / educational only. NOT financial advice; no guarantee of profitability or accuracy. Indicators describe past behaviour; they do not predict the future. Trading carries risk of loss. Test out-of-sample and make your own decisions. The author accepts no liability
Overview
A complete intraday opening-range-breakout engine. For each session it auto-detects the open, builds the opening range (the high–low band of the first N minutes, where the day's initial balance is set), and then does the three things most opening-range scripts leave out: it filters the day for tradability, it projects a trade map (targets and a stop) scaled to that day's own volatility, and it keeps an honest, on-chart win-rate tally of how often breaks actually reach their first target before the stop. It draws the structure and the map; it does not place orders. Analytical tool, not advice.
What makes it different — why these pieces are ONE engine (mashup rationale)
The opening range is the substrate — the reference band the whole day is measured against (ORH / ORL / midpoint).
The relative-volume ("in play") filter asks whether the range formed on above-average volume — the single biggest edge driver in the research. A break on a quiet day and a break on an active day are not the same event, so the engine measures the range's volume against a rolling average of prior sessions' opening-range volume and flags it.
The direction filter can require the break to agree with the opening-range candle's own direction, dropping the counter-range breaks that fare worst.
The accepted-break logic (close beyond the edge, optionally held a bar) separates a real initiative move from a wick.
The trade map projects targets (as range multiples or risk/R multiples) and a stop (opposite edge, range midpoint, or an ATR distance), so the plan scales to each day's volatility instead of fixed points — and reports the resulting R:R.
The win-rate harness closes the loop: it tracks every break until it tags target 1 or the stop and reports a real, path-aware Hit % and Edge on your instrument (optionally in-play only), logging unresolved breaks as end-of-day exits separately.
The failed-break module handles the other half of reality: a break that closes back inside the range traps breakout traders, so the engine flags it, projects the reversal to the opposite edge (stop at the failure extreme), and runs a second harness measuring how often that fade reaches the opposite edge before the failure is re-broken. A retest-hold flag marks the high-probability continuation entry; a trap flag marks both-edges-broken days; a range-state read (compressed / normal / wide) says what kind of break you're looking at.
Split apart, each piece is a fragment: a box without the filters is noise, targets without the harness are guesses, and a break with no failure case is half the picture. Chained, they answer one question — is this opening-range break worth taking here, and if it fails, is the fade? That interdependence is why it's a single engine, not a bundle.
What this adds over a standard opening-range script
Most ORB scripts stop at drawing the box and the two breakout lines. This engine adds the parts that decide and verify:
Relative-volume "in play" filter. Flags whether today's opening range formed on above-average volume — research-shown to be the dominant driver of opening-range edge — with an optional toggle to count only in-play days in the stats.
Range-direction filter. Optionally restricts breaks to the direction the opening-range candle closed, removing the weakest counter-range trades.
Volatility-scaled trade map. Targets as range or R (risk) multiples; stop at the opposite edge, the range midpoint, or an ATR distance — with the live R:R shown.
Path-aware win-rate harness. Tracks each break to target 1 or stop and reports an honest Hit % / Edge (vs a 50% coin-flip), counting end-of-day exits separately — a real, in-sample reality check, not a curve-fit claim.
Failed-break reversal module. Detects the break that closes back inside the range (a fakeout — research puts breakout failure rates in the 60–80% range), projects the fade toward the opposite edge with the failure extreme as its stop, and runs a second harness reporting how often the fade reaches that edge first. A failed break is often the better trade, and almost no ORB script measures it.
Retest-hold, trap and range-state context. A retest-hold flag marks the broken edge holding as support/resistance (the higher-probability continuation entry); a trap flag marks both-edges-broken whipsaw days; a range-state read (compressed / normal / wide vs the rolling average) says whether the break is likely to run or fail.
Reference levels with built-in legends. Current-day H/L, prior-day H/L (PDH/PDL) and prior-week H/L (PWH/PWL) — the most-watched intraday liquidity pools — are drawn as labelled lines that extend right, each tagged (DH/DL/PDH/PDL/PWH/PWL) so every line identifies itself. A Day position read shows whether price is above PDH, inside the prior-day range, or below PDL.
Liquidity-sweep detection, fused with the failure logic. A sweep — price wicks beyond PDH/PDL/PWH/PWL and closes back inside, taking the stops there — is flagged with a marker and in the dashboard. Because the opening-range edges are themselves prime liquidity, a failed ORB break that sweeps a level is the highest-conviction version of the fade; the engine ties the two together.
Institution-grade, readable visuals. Events are compact bar-anchored markers (triangle / cross / circle / flag) instead of stacked labels; key levels are drawn as glowing lines with bold colour-coded legend chips at the right edge; a legend-key panel decodes every mark and line; and only the most recent sessions' drawings are kept, so the chart stays clean even after months of history. The dashboard and legend key are theme-adaptive — they auto-match a light or dark chart background for proper contrast.
Auto-session that works where others break. New-session detection keys off a calendar-day change in the instrument's own timezone, so it resets correctly even on feeds with no out-of-session bars (NSE index futures only print 09:15–15:30) — where edge-detection scripts silently fail.
Fused decision dashboard. Break state, ORH/ORL, range, range state, range direction, relative volume / in-play, targets, stop, R:R, day position vs the prior day, liquidity-sweep status, the running Hit % / Edge, the failed-break fade and its Hit % / Edge, and retest/trap status — theme-adaptive to your chart.
How it works
Session: Auto groups by the instrument's trading day in its native timezone (works even with no out-of-session bars); Manual pins a window. Range: the high/low of the first N minutes become ORH/ORL; the midpoint is the pivot; the range candle's close-vs-open sets the range direction; its volume vs a rolling average gives the relative-volume "in play" read; its size vs a rolling average gives the range state (compressed / normal / wide). Break: the first close beyond ORH (long) or ORL (short) after the range completes, optionally held a bar and optionally restricted to the range direction. Map: targets = break edge + range multiples, or entry + risk (R) multiples; stop = opposite edge, range midpoint, or an ATR distance. Harness: each break is followed until it tags target 1 or the stop; unresolved breaks at the close are logged as end-of-day exits, separate from the Hit %. Failure: if an accepted break closes back inside the range it is flagged failed; the reversal targets the opposite edge with the failure extreme as stop, and a separate fade harness reports how often that reversal reaches the opposite edge before the failure extreme is re-broken. A retest of the broken edge that holds is flagged continuation; both edges breaking is flagged a trap. Levels: current-day H/L (tracked live), prior-day H/L and prior-week H/L (from the weekly series) are drawn as labelled lines (DH/DL, PDH/PDL, PWH/PWL) extending right. Liquidity: a sweep is a bar that wicks a set fraction of ATR beyond PDH/PDL/PWH/PWL then closes back inside — the stops there are taken and price rejects — flagged with a marker and in the dashboard alongside the day-position read.
How to use
Trade with an accepted break toward target 1 / 2, invalidated back inside the range (or at the chosen stop); favour in-play, range-direction and compressed-range breaks, and breaks that also clear PDH / PWH (genuine acceptance through liquidity) — all shown to carry the edge. When a break fails back inside, or sweeps a key level and rejects, the fade toward the opposite edge is often the better trade — the dashboard's fade Hit % / Edge tells you whether it has paid here. A retest that holds confirms continuation; a trap (both edges broken) is usually a stand-aside. Use the Hit % / Edge reads as a reality check before relying on any of it. Context for your decisions — not a standalone trigger.
Universal across markets (configurable data source)
High / low / close sources, the session mode / window / timezone and the range length are all inputs, so the engine runs on any instrument and intraday timeframe. Defaults target NSE NIFTY index futures with a first-15-minute range (the research tested 5 / 15 / 30 / 60 minutes; 5 was best on US single stocks). Change the sources, session and range for any other market. Use an intraday chart; the relative-volume filter needs a real volume feed and degrades gracefully without one.
Originality
The opening-range, fakeout-reversal and liquidity concepts are public (credited below); the original work is the assembly and the code — auto-session detection that works on instruments with no out-of-session bars, the relative-volume "in play" / range-direction / range-state filters, the range / R-multiple trade map with ATR stop and end-of-day exit, the path-aware win-rate harness, the failed-break reversal module with its own fade harness, and the reference-level + liquidity-sweep engine that ties the break to prior-day / prior-week liquidity. No third-party code is reused.
Companion drawings (TradingView compliance note)
Everything this plots is part of the one engine and is explained above — the opening-range box, the ORH/ORL/midpoint lines, the day/week reference levels (DH/DL, PDH/PDL, PWH/PWL) with their right-edge legends, the bar-anchored break / failed / retest / sweep markers, the target / stop / reversal lines, the legend-key panel, and the dashboard. There are no unrelated studies. Before publishing, clean the chart so only this indicator is shown.
Concept credit
The opening-range-breakout concept is long-standing market lore, formalised by Toby Crabel ("Day Trading with Short Term Price Patterns and Opening Range Breakout") and related to Mark B. Fisher's ACD method ("The Logical Trader"). The relative-volume "stocks in play" filter and the range-direction entry follow the empirical study of Zarattini, Barbon & Aziz (2023–24). The failed-breakout (fakeout) reversal and retest-hold continuation are classic price-action concepts, and prior-day / prior-week liquidity with the liquidity-sweep (stop-raid-then-reject) read are general price-action / Smart-Money-Concept ideas in wide public use. Implementation is original; not affiliated with, nor endorsed by, any third party, and no third-party code is reused.
Honesty / limitations
The Hit % is path-aware but in-sample, ignores costs and slippage, assumes the target/stop fills exactly at touch, and counts one break per session — descriptive context, not a verified backtest. Opening-range behaviour varies by instrument, session and regime. This engine maps structure; it does not predict which breaks will work.
Disclaimer
Research / educational only. NOT financial advice; no guarantee of profitability or accuracy. Indicators describe past behaviour; they do not predict the future. Trading carries risk of loss. Test out-of-sample and make your own decisions. The author accepts no liability
Notas de Lançamento
Removed Trade engine for further CalibrationScript de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.