OPEN-SOURCE SCRIPT
PM Range Breaker [CHE]

PM Range Breaker [CHE] — Premarket bias with first-five range breaks, optional SWDEMA regime latch, and simple two-times-range targets
Summary
This indicator sets a once-per-day directional bias during New York premarket and then tracks a strict first-five-minutes range from the session open. After the first five complete, it marks clean breakouts and can project targets at two times the measured range. A second mode latches an EMA-based regime to inform the bias and optional background tinting. A compact panel reports live state, first-five levels, and rolling hit rates of both bias modes using a user-defined midday close for statistics.
Motivation: Why this design?
Intraday traders often get whipsawed by early noise or by fast flips in trend filters. This script commits to a bias at a single premarket minute and then waits for the market to present an objective structure: the first-five range. Breaks after that window are clearer and easier to manage. The alternative SWDEMA regime gives a slower, latched context for users who prefer a trend scaffold rather than a midpoint reference.
What’s different vs. standard approaches?
Baseline: Typical open-range-breakout lines or a single moving-average filter without daily commitment.
Architecture differences:
Bias decision at a fixed New York time using either a midpoint lookback (“Classic”) or a two-EMA regime latch (“SWDEMA”).
Strict five-minute window from session open; breakout shapes print only after that window.
Single-shot breakout direction per session (debounce) and optional two-times-range targets.
On-chart panel with hit rates using a configurable midday close for statistics.
Practical effect: Cleaner visuals, fewer repeated signals, and a traceable daily decision that can be evaluated over time.
How it works (technical)
Time handling uses New York session times for premarket decision, open, first-five end, and a midday statistics checkpoint.
Classic bias: A midpoint is computed from the highest and lowest over a user period; at the premarket minute, the bias is set long when the close is above the midpoint, short otherwise.
SWDEMA bias: Two EMAs define a regime score that requires price and trend agreement; when both agree on a confirmed bar, the regime latches. At the premarket minute, the daily bias is set from the current regime.
The first-five range captures high and low from open until the end minute, then freezes. Breakouts are detected after that window using close-based cross logic.
The script draws range lines and optional targets at two times the frozen range. A session break direction latch prevents duplicate break markers.
Statistics compare daily open and a configurable midday close to record if the chosen bias aligned with the move.
Optional elements include EMA lines, midpoint line, latched-regime background, and regime switch markers.
Data aggregation for day logic and the first-five window is sampled on one-minute data with explicit lookahead off. On charts above one minute, values update intra-bar until the underlying minute closes.
Parameter Guide
Premarket Start (NY) — Minute when the bias is decided — Default: 08:30 — Move earlier for more stability; later for recency.
Market Open (NY) — Session start used for the first-five window — Default: 09:30 — Align to instrument’s RTH if different.
First-5 End (NY) — End of the first-five window — Default: 09:35 — Extend slightly to capture wider opening ranges.
Day End (NY) for Stats — Midday checkpoint for hit rate — Default: 12:00 — Use a later time for a longer evaluation window.
Show First-5 Lines — Draw the frozen range lines — Default: On — Turn off if your chart is crowded.
Show Bias Background (Session) — Tint by daily bias during session — Default: On — Useful for directional context.
Show Break Shapes — Print breakout triangles — Default: On — Disable if you only want lines and alerts.
Show 2R Targets (Optional) — Plot targets at two times the range — Default: On — Switch off if you manage exits differently.
Line Length Right — Extension length of drawn lines — Default: 20 (bars) — Increase for slower timeframes.
High/Low Line Colors — Visual colors for range levels — Defaults: Green/Red — Adjust to your theme.
Long/Short Bias Colors — Background tints — Defaults: Green/Red with high transparency — Lower transparency for stronger emphasis.
Show Corner Panel — Enable the info panel — Default: On — Centralizes status and numbers.
Show Hit Rates in Panel — Include success rates — Default: On — Turn off to reduce panel rows.
Panel Position — Anchor on chart — Default: Top right — Move to avoid overlap.
Panel Size — Text size in panel — Default: Small — Increase on high-resolution displays.
Dark Panel — Dark theme for the panel — Default: On — Match your chart background.
Show EMA Lines — Plot blue and red EMAs — Default: Off — Enable for SWDEMA context.
Show Midpoint Line — Plot the midpoint — Default: Off — Useful for Classic mode visualization.
Midpoint Lookback Period — Bars for high-low midpoint — Default: 300 — Larger values stabilize; smaller values respond faster.
Midpoint Line Color — Color for midpoint — Default: Gray — A neutral line works best.
SWDEMA Lengths (Blue/Red) — Periods for the two EMAs — Defaults: 144 and 312 — Longer values reduce flips.
Sources (Blue/Red) — Price sources — Defaults: Close and HLC3 — Adjust if you prefer consistency.
Offsets (Blue/Red) — Pixel offsets for EMA plots — Defaults: zero — Use only for visual shift.
Show Latched Regime Background — Background by SWDEMA regime — Default: Off — Separate from session bias.
Latched Background Transparency — Opacity of regime background — Default: eighty-eight — Lower value for stronger tint.
Show Latch Switch Markers — Plot regime change markers — Default: Off — For auditing regime changes.
Bias Mode — Classic midpoint or SWDEMA latch — Default: Classic — Choose per your style.
Background Mode — Session bias or SWDEMA regime — Default: Session — Decide which background narrative you want.
Reading & Interpretation
Panel: Shows the active bias, first-five high and low, and a state that reads Building during the window, Ready once frozen, and Break arrows when a breakout occurs. Hit rates show the percentage of days where each bias mode aligned with the midday move.
Colors and shapes: Green background implies long bias; red implies short bias. Triangle markers denote the first valid breakout after the first-five window. Optional regime markers flag regime changes.
Lines: First-five high and low form the core structure. Optional targets mark a level at two times the frozen range from the breakout side.
Practical Workflows & Combinations
Trend following: Choose a bias mode. Wait for the first clean breakout after the first-five window in the direction of the bias. Confirm with structure such as higher highs and higher lows or lower highs and lower lows.
Exits and risk: Conservative users can trail behind the opposite side of the first-five range. Aggressive users can scale near the two-times-range target.
Multi-asset and multi-TF: Works well on intraday timeframes from one minute upward. For non-US sessions, adjust the time inputs to the instrument’s regular trading hours.
Behavior, Constraints & Performance
Repaint and confirmation: Bias and regime decisions use confirmed bars. Breakout signals evaluate on bar close at the chart timeframe. On higher timeframes, minute-based sources update within the live bar until the minute closes.
security and HTF: The script samples one-minute data. Lookahead is off. Values stabilize once the source minute closes.
Resources: `max_bars_back` is five thousand. Drawing objects and the panel update efficiently, with position extensions handled on the last bar.
Known limits: Midday statistics use the configured time, not the official daily close. Session logic assumes New York session timing. Targets are simple multiples of the first-five range and do not adapt to volatility beyond that structure.
Sensible Defaults & Quick Tuning
Start with Classic bias, midpoint lookback at three hundred, and all visuals on.
Too many flips in context → switch to SWDEMA mode or increase EMA lengths.
Breakouts feel noisy → extend the first-five end by a minute or two, or wait for a retest by your own rules.
Too sluggish → reduce midpoint lookback or shorten EMA lengths.
Chart cluttered → hide EMA or midpoint lines and keep only range levels and breakout shapes.
What this indicator is—and isn’t
This is a visualization and signal layer for session bias and first-five structure. It does not manage orders, position sizing, or risk. It is not predictive. Use it alongside market structure, execution rules, and independent risk controls.
Disclaimer
The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.
Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.
By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
Do not use this indicator on Heikin-Ashi, Renko, Kagi, Point-and-Figure, or Range charts, as these chart types can produce unrealistic results for signal markers and alerts.
Best regards and happy trading
Chervolino
Many thanks to LonesomeTheBlue
for the original work. I adapted the midpoint calculation for this script. tradingview.com/u/LonesomeTheBlue
Summary
This indicator sets a once-per-day directional bias during New York premarket and then tracks a strict first-five-minutes range from the session open. After the first five complete, it marks clean breakouts and can project targets at two times the measured range. A second mode latches an EMA-based regime to inform the bias and optional background tinting. A compact panel reports live state, first-five levels, and rolling hit rates of both bias modes using a user-defined midday close for statistics.
Motivation: Why this design?
Intraday traders often get whipsawed by early noise or by fast flips in trend filters. This script commits to a bias at a single premarket minute and then waits for the market to present an objective structure: the first-five range. Breaks after that window are clearer and easier to manage. The alternative SWDEMA regime gives a slower, latched context for users who prefer a trend scaffold rather than a midpoint reference.
What’s different vs. standard approaches?
Baseline: Typical open-range-breakout lines or a single moving-average filter without daily commitment.
Architecture differences:
Bias decision at a fixed New York time using either a midpoint lookback (“Classic”) or a two-EMA regime latch (“SWDEMA”).
Strict five-minute window from session open; breakout shapes print only after that window.
Single-shot breakout direction per session (debounce) and optional two-times-range targets.
On-chart panel with hit rates using a configurable midday close for statistics.
Practical effect: Cleaner visuals, fewer repeated signals, and a traceable daily decision that can be evaluated over time.
How it works (technical)
Time handling uses New York session times for premarket decision, open, first-five end, and a midday statistics checkpoint.
Classic bias: A midpoint is computed from the highest and lowest over a user period; at the premarket minute, the bias is set long when the close is above the midpoint, short otherwise.
SWDEMA bias: Two EMAs define a regime score that requires price and trend agreement; when both agree on a confirmed bar, the regime latches. At the premarket minute, the daily bias is set from the current regime.
The first-five range captures high and low from open until the end minute, then freezes. Breakouts are detected after that window using close-based cross logic.
The script draws range lines and optional targets at two times the frozen range. A session break direction latch prevents duplicate break markers.
Statistics compare daily open and a configurable midday close to record if the chosen bias aligned with the move.
Optional elements include EMA lines, midpoint line, latched-regime background, and regime switch markers.
Data aggregation for day logic and the first-five window is sampled on one-minute data with explicit lookahead off. On charts above one minute, values update intra-bar until the underlying minute closes.
Parameter Guide
Premarket Start (NY) — Minute when the bias is decided — Default: 08:30 — Move earlier for more stability; later for recency.
Market Open (NY) — Session start used for the first-five window — Default: 09:30 — Align to instrument’s RTH if different.
First-5 End (NY) — End of the first-five window — Default: 09:35 — Extend slightly to capture wider opening ranges.
Day End (NY) for Stats — Midday checkpoint for hit rate — Default: 12:00 — Use a later time for a longer evaluation window.
Show First-5 Lines — Draw the frozen range lines — Default: On — Turn off if your chart is crowded.
Show Bias Background (Session) — Tint by daily bias during session — Default: On — Useful for directional context.
Show Break Shapes — Print breakout triangles — Default: On — Disable if you only want lines and alerts.
Show 2R Targets (Optional) — Plot targets at two times the range — Default: On — Switch off if you manage exits differently.
Line Length Right — Extension length of drawn lines — Default: 20 (bars) — Increase for slower timeframes.
High/Low Line Colors — Visual colors for range levels — Defaults: Green/Red — Adjust to your theme.
Long/Short Bias Colors — Background tints — Defaults: Green/Red with high transparency — Lower transparency for stronger emphasis.
Show Corner Panel — Enable the info panel — Default: On — Centralizes status and numbers.
Show Hit Rates in Panel — Include success rates — Default: On — Turn off to reduce panel rows.
Panel Position — Anchor on chart — Default: Top right — Move to avoid overlap.
Panel Size — Text size in panel — Default: Small — Increase on high-resolution displays.
Dark Panel — Dark theme for the panel — Default: On — Match your chart background.
Show EMA Lines — Plot blue and red EMAs — Default: Off — Enable for SWDEMA context.
Show Midpoint Line — Plot the midpoint — Default: Off — Useful for Classic mode visualization.
Midpoint Lookback Period — Bars for high-low midpoint — Default: 300 — Larger values stabilize; smaller values respond faster.
Midpoint Line Color — Color for midpoint — Default: Gray — A neutral line works best.
SWDEMA Lengths (Blue/Red) — Periods for the two EMAs — Defaults: 144 and 312 — Longer values reduce flips.
Sources (Blue/Red) — Price sources — Defaults: Close and HLC3 — Adjust if you prefer consistency.
Offsets (Blue/Red) — Pixel offsets for EMA plots — Defaults: zero — Use only for visual shift.
Show Latched Regime Background — Background by SWDEMA regime — Default: Off — Separate from session bias.
Latched Background Transparency — Opacity of regime background — Default: eighty-eight — Lower value for stronger tint.
Show Latch Switch Markers — Plot regime change markers — Default: Off — For auditing regime changes.
Bias Mode — Classic midpoint or SWDEMA latch — Default: Classic — Choose per your style.
Background Mode — Session bias or SWDEMA regime — Default: Session — Decide which background narrative you want.
Reading & Interpretation
Panel: Shows the active bias, first-five high and low, and a state that reads Building during the window, Ready once frozen, and Break arrows when a breakout occurs. Hit rates show the percentage of days where each bias mode aligned with the midday move.
Colors and shapes: Green background implies long bias; red implies short bias. Triangle markers denote the first valid breakout after the first-five window. Optional regime markers flag regime changes.
Lines: First-five high and low form the core structure. Optional targets mark a level at two times the frozen range from the breakout side.
Practical Workflows & Combinations
Trend following: Choose a bias mode. Wait for the first clean breakout after the first-five window in the direction of the bias. Confirm with structure such as higher highs and higher lows or lower highs and lower lows.
Exits and risk: Conservative users can trail behind the opposite side of the first-five range. Aggressive users can scale near the two-times-range target.
Multi-asset and multi-TF: Works well on intraday timeframes from one minute upward. For non-US sessions, adjust the time inputs to the instrument’s regular trading hours.
Behavior, Constraints & Performance
Repaint and confirmation: Bias and regime decisions use confirmed bars. Breakout signals evaluate on bar close at the chart timeframe. On higher timeframes, minute-based sources update within the live bar until the minute closes.
security and HTF: The script samples one-minute data. Lookahead is off. Values stabilize once the source minute closes.
Resources: `max_bars_back` is five thousand. Drawing objects and the panel update efficiently, with position extensions handled on the last bar.
Known limits: Midday statistics use the configured time, not the official daily close. Session logic assumes New York session timing. Targets are simple multiples of the first-five range and do not adapt to volatility beyond that structure.
Sensible Defaults & Quick Tuning
Start with Classic bias, midpoint lookback at three hundred, and all visuals on.
Too many flips in context → switch to SWDEMA mode or increase EMA lengths.
Breakouts feel noisy → extend the first-five end by a minute or two, or wait for a retest by your own rules.
Too sluggish → reduce midpoint lookback or shorten EMA lengths.
Chart cluttered → hide EMA or midpoint lines and keep only range levels and breakout shapes.
What this indicator is—and isn’t
This is a visualization and signal layer for session bias and first-five structure. It does not manage orders, position sizing, or risk. It is not predictive. Use it alongside market structure, execution rules, and independent risk controls.
Disclaimer
The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.
Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.
By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
Do not use this indicator on Heikin-Ashi, Renko, Kagi, Point-and-Figure, or Range charts, as these chart types can produce unrealistic results for signal markers and alerts.
Best regards and happy trading
Chervolino
Many thanks to LonesomeTheBlue
for the original work. I adapted the midpoint calculation for this script. tradingview.com/u/LonesomeTheBlue
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.