OPEN-SOURCE SCRIPT
First-Move-Wrong Toolkit [CHE]

First-Move-Wrong Toolkit [CHE] — Session-bound sweep rejection with structure confirmation
Summary
This indicator marks potential “first move wrong” reversals during a defined trading session. It looks for a quick sweep beyond the prior day high or low, or the opening range high or low, followed by rejection and a basic structure confirmation. Optional rules require a retest and a VWAP reclaim in the direction of the trade idea. The script renders session levels as right-extended lines, signals as labels, optional SL/TP guide lines for visualization, and background tints during sweep events. Pivots are confirmed using swing width, which reduces repaint risk compared to live swings.
Motivation: Why this design?
Intraday reversals often start with a liquidity sweep around obvious highs or lows. Acting on the sweep alone can be noisy, while waiting for structure break and a retest can be slow. This tool balances both by checking a sweep and rejection at session-relevant levels, then requiring a simple structure cue and, optionally, a retest and a VWAP filter. The goal is a clear, rule-based signal layer that is easy to audit on chart without hidden state.
What’s different vs. standard approaches?
Baseline reference: Simple sweep detectors or basic CHOCH markers that ignore session context and liquidity anchors.
Architecture differences:
Session-aware opening range tracking that finalizes after the chosen minutes from session start.
Daily previous high and low pulled without lookahead, then extended forward as visual anchors.
Confirmed pivot highs and lows to avoid repaint from live, unconfirmed swings.
Optional retest rule using crossover or crossunder at the trigger level.
Optional VWAP filter to demand reclaim in the intended direction.
Global label cooldown to prevent clusters of signals.
Practical effect: Fewer one-off flips around noisy levels, clearer alignment with session structure, and compact visual feedback through lines, labels, and tints.
How it works (technical)
Levels: During the defined session, the script builds an opening range high and low until the configured minute mark after session start, then freezes those levels for the day. It also fetches the previous day high and low from the daily timeframe without lookahead and extends them forward.
Sweep and rejection: A sweep is defined as price moving beyond a target level and then rejecting back inside on the same bar. The script checks this condition separately for highs and lows against opening range and previous-day levels.
Structure validation: Confirmed pivot highs and lows are computed using a symmetric swing width. A bearish idea requires a prior sweep of a high plus a break through the last confirmed swing low. A bullish idea requires a prior sweep of a low plus a break through the last confirmed swing high.
Optional retest: If enabled, a bearish signal needs a cross under the bearish trigger level; a bullish signal needs a cross over the bullish trigger level.
VWAP filter (optional): The script requires a reclaim of VWAP in the intended direction when enabled.
State handling: Opening range values, previous-day lines, and the label cooldown timestamp are stored in persistent variables. Lines are created once and updated each bar to extend forward.
Repaint considerations: Pivots confirm only after the specified swing width, reducing repaint. The daily level request is performed without lookahead. Signals use closed-bar checks implied by crossover and crossunder logic.
Parameter Guide
Session (local) — Defines the active trading window. Default nine to seventeen. Narrower windows focus on the main session drive.
Opening Range (min) — Minutes from session start to finalize OR levels. Default fifteen. Shorter values react faster; longer values stabilize levels.
Use PrevDay H/L levels — Toggle previous-day anchors. On by default.
Use OR H/L levels — Toggle opening range anchors. On by default.
Equal H/L tolerance (ticks) — Intended tolerance for equal highs or lows. Default one. (Unknown/Optional) in current signals.
Swing width — Bars on both sides for confirmed pivots. Default two. Larger values reduce noise but confirm later.
Require CHOCH after sweep — Enforces structure break after a sweep. On by default.
Prefer retest entries — Requires crossover or crossunder of the trigger level. On by default.
VWAP filter — Demands a reclaim of VWAP in signal direction. Off by default.
TP in R (guide) — Multiplier for visual TP guides. Default one. Visualization only.
Show levels / Show signals / Show R-guides — Rendering toggles. R-guides are visual aids, not orders.
Label cooldown (bars) — Minimum bars between labels. Default five. Higher values reduce clusters.
Palette inputs — Colors and transparencies for levels, labels, VWAP, and tints.
Reading & Interpretation
Lines: Dotted lines represent opening range high and low after the OR window completes. Dashed lines represent previous-day high and low.
Signals: “Long” labels appear after a low-side sweep with rejection and structure confirmation, subject to optional retest and VWAP rules. “Short” labels mirror this on the high side.
Background tints: Red-tinted bars indicate a high-side sweep and rejection. Green-tinted bars indicate a low-side sweep and rejection.
R-guides: Circles display a visual stop level at the bar extreme and a target guide based on the selected multiple. They are informational only.
Practical Workflows & Combinations
Session reversal scans: During the first hour, watch for sweeps around previous-day or opening range levels, then wait for structure confirmation and optional retest.
Trend following with filters: Combine signals with higher-timeframe structure or a moving average regime check. Ignore signals against the dominant regime.
Exits and stops: Use the visual stop as a reference near the sweep extreme; adapt the target guide to volatility and market conditions.
Multi-asset / Multi-TF: Works on intraday timeframes for liquid futures, indices, forex, and large-cap equities. Start with default settings and adjust swing width and OR minutes to instrument volatility.
Behavior, Constraints & Performance
Repaint/confirmation: Pivots confirm after the swing window completes. Signals occur only when conditions are met on closed bars.
security()/HTF: Daily previous-day levels are requested without lookahead to reduce repaint.
Resources: Uses persistent variables and line updates per bar; no heavy loops or arrays.
Known limits: Signals can arrive later when swing width is large. Gaps around session boundaries may distort OR levels. VWAP behavior may vary with partial sessions or illiquid assets.
Sensible Defaults & Quick Tuning
Starting point: Session nine to seventeen, opening range fifteen minutes, swing width two, CHOCH required, retest on, VWAP off, cooldown five bars.
Too many flips: Increase swing width, enable VWAP filter, or raise label cooldown.
Too sluggish: Reduce swing width or shorten the opening range window.
Too many session-level hits: Disable either previous-day levels or opening range levels to simplify context.
What this indicator is—and isn’t
This is a session-aware visualization and signal layer focused on sweep-plus-structure behavior. It is not a complete trading system and does not manage orders, risk, or portfolio exposure. Use it with market structure, risk limits, and execution rules that fit your process.
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
Summary
This indicator marks potential “first move wrong” reversals during a defined trading session. It looks for a quick sweep beyond the prior day high or low, or the opening range high or low, followed by rejection and a basic structure confirmation. Optional rules require a retest and a VWAP reclaim in the direction of the trade idea. The script renders session levels as right-extended lines, signals as labels, optional SL/TP guide lines for visualization, and background tints during sweep events. Pivots are confirmed using swing width, which reduces repaint risk compared to live swings.
Motivation: Why this design?
Intraday reversals often start with a liquidity sweep around obvious highs or lows. Acting on the sweep alone can be noisy, while waiting for structure break and a retest can be slow. This tool balances both by checking a sweep and rejection at session-relevant levels, then requiring a simple structure cue and, optionally, a retest and a VWAP filter. The goal is a clear, rule-based signal layer that is easy to audit on chart without hidden state.
What’s different vs. standard approaches?
Baseline reference: Simple sweep detectors or basic CHOCH markers that ignore session context and liquidity anchors.
Architecture differences:
Session-aware opening range tracking that finalizes after the chosen minutes from session start.
Daily previous high and low pulled without lookahead, then extended forward as visual anchors.
Confirmed pivot highs and lows to avoid repaint from live, unconfirmed swings.
Optional retest rule using crossover or crossunder at the trigger level.
Optional VWAP filter to demand reclaim in the intended direction.
Global label cooldown to prevent clusters of signals.
Practical effect: Fewer one-off flips around noisy levels, clearer alignment with session structure, and compact visual feedback through lines, labels, and tints.
How it works (technical)
Levels: During the defined session, the script builds an opening range high and low until the configured minute mark after session start, then freezes those levels for the day. It also fetches the previous day high and low from the daily timeframe without lookahead and extends them forward.
Sweep and rejection: A sweep is defined as price moving beyond a target level and then rejecting back inside on the same bar. The script checks this condition separately for highs and lows against opening range and previous-day levels.
Structure validation: Confirmed pivot highs and lows are computed using a symmetric swing width. A bearish idea requires a prior sweep of a high plus a break through the last confirmed swing low. A bullish idea requires a prior sweep of a low plus a break through the last confirmed swing high.
Optional retest: If enabled, a bearish signal needs a cross under the bearish trigger level; a bullish signal needs a cross over the bullish trigger level.
VWAP filter (optional): The script requires a reclaim of VWAP in the intended direction when enabled.
State handling: Opening range values, previous-day lines, and the label cooldown timestamp are stored in persistent variables. Lines are created once and updated each bar to extend forward.
Repaint considerations: Pivots confirm only after the specified swing width, reducing repaint. The daily level request is performed without lookahead. Signals use closed-bar checks implied by crossover and crossunder logic.
Parameter Guide
Session (local) — Defines the active trading window. Default nine to seventeen. Narrower windows focus on the main session drive.
Opening Range (min) — Minutes from session start to finalize OR levels. Default fifteen. Shorter values react faster; longer values stabilize levels.
Use PrevDay H/L levels — Toggle previous-day anchors. On by default.
Use OR H/L levels — Toggle opening range anchors. On by default.
Equal H/L tolerance (ticks) — Intended tolerance for equal highs or lows. Default one. (Unknown/Optional) in current signals.
Swing width — Bars on both sides for confirmed pivots. Default two. Larger values reduce noise but confirm later.
Require CHOCH after sweep — Enforces structure break after a sweep. On by default.
Prefer retest entries — Requires crossover or crossunder of the trigger level. On by default.
VWAP filter — Demands a reclaim of VWAP in signal direction. Off by default.
TP in R (guide) — Multiplier for visual TP guides. Default one. Visualization only.
Show levels / Show signals / Show R-guides — Rendering toggles. R-guides are visual aids, not orders.
Label cooldown (bars) — Minimum bars between labels. Default five. Higher values reduce clusters.
Palette inputs — Colors and transparencies for levels, labels, VWAP, and tints.
Reading & Interpretation
Lines: Dotted lines represent opening range high and low after the OR window completes. Dashed lines represent previous-day high and low.
Signals: “Long” labels appear after a low-side sweep with rejection and structure confirmation, subject to optional retest and VWAP rules. “Short” labels mirror this on the high side.
Background tints: Red-tinted bars indicate a high-side sweep and rejection. Green-tinted bars indicate a low-side sweep and rejection.
R-guides: Circles display a visual stop level at the bar extreme and a target guide based on the selected multiple. They are informational only.
Practical Workflows & Combinations
Session reversal scans: During the first hour, watch for sweeps around previous-day or opening range levels, then wait for structure confirmation and optional retest.
Trend following with filters: Combine signals with higher-timeframe structure or a moving average regime check. Ignore signals against the dominant regime.
Exits and stops: Use the visual stop as a reference near the sweep extreme; adapt the target guide to volatility and market conditions.
Multi-asset / Multi-TF: Works on intraday timeframes for liquid futures, indices, forex, and large-cap equities. Start with default settings and adjust swing width and OR minutes to instrument volatility.
Behavior, Constraints & Performance
Repaint/confirmation: Pivots confirm after the swing window completes. Signals occur only when conditions are met on closed bars.
security()/HTF: Daily previous-day levels are requested without lookahead to reduce repaint.
Resources: Uses persistent variables and line updates per bar; no heavy loops or arrays.
Known limits: Signals can arrive later when swing width is large. Gaps around session boundaries may distort OR levels. VWAP behavior may vary with partial sessions or illiquid assets.
Sensible Defaults & Quick Tuning
Starting point: Session nine to seventeen, opening range fifteen minutes, swing width two, CHOCH required, retest on, VWAP off, cooldown five bars.
Too many flips: Increase swing width, enable VWAP filter, or raise label cooldown.
Too sluggish: Reduce swing width or shorten the opening range window.
Too many session-level hits: Disable either previous-day levels or opening range levels to simplify context.
What this indicator is—and isn’t
This is a session-aware visualization and signal layer focused on sweep-plus-structure behavior. It is not a complete trading system and does not manage orders, risk, or portfolio exposure. Use it with market structure, risk limits, and execution rules that fit your process.
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
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.