OPEN-SOURCE SCRIPT
Updated HTF Cross Breakout [CHE]

HTF Cross Breakout [CHE] — Detects higher timeframe close crossovers for breakout signals, anchors VWAP for trend validation, and flags continuations or traps with visual extensions for delta percent and stop levels.
Summary
This indicator spots moments when the current chart's close price crosses a higher timeframe close, marking potential breakouts only when the current bar shows directional strength. It anchors a volume-weighted average price line from the breakout point to track trend health, updating labels to show if the move continues or reverses into a trap. Extensions add a dotted line linking the breakout level to the current close with percent change display, plus a stop-loss marker at the VWAP end. Signals gain robustness from higher timeframe confirmation and anti-repainting options, reducing noise in live bars compared to simple crossover tools.
Motivation: Why this design?
Traders often face false breakouts from intrabar wiggles on lower timeframes, especially without higher timeframe alignment, leading to whipsaws in volatile sessions. This design uses higher timeframe close as a stable reference for crossover detection, combined with anchored volume weighting to gauge sustained momentum. It addresses these by enforcing bar confirmation and directional filters, providing clearer entry validation and risk points without overcomplicating the chart.
What’s different vs. standard approaches?
Reference baseline
Standard crossover indicators like moving average crosses operate solely on the chart timeframe, ignoring higher timeframe context and lacking volume anchoring.
Architecture differences
- Higher timeframe data pulls via security calls with optional repainting control for stability.
- Anchored VWAP resets at each signal, accumulating from the breakout bar only.
- Label dynamics update in real-time for continuation checks, with extensions for visual delta and stop computation.
- Event-driven line finalization prunes old elements after a set bar extension.
Practical effect
Charts show persistent lines and labels that extend live but finalize cleanly on new events, avoiding clutter. This matters for spotting trap reversals early via label color shifts, and extensions provide quick risk visuals without manual calculations, improving decision speed in trend trades.
How it works (technical)
The indicator first determines a higher timeframe based on user selection, pulling its close price securely. It checks for crossovers or crossunders of the current close against this higher close, but only triggers on confirmed bars with matching directional opens and closes. On a valid event, a horizontal line and label mark the higher close level, while a dashed VWAP line starts accumulating typical price times volume from that bar onward. During the active phase, the breakout line extends to the current bar, the label repositions and updates text based on whether the current close holds above or below the level for bulls or bears. A background tint warns if the close deviates adversely from the current VWAP. Extensions draw a vertical dotted line at the last bar between the breakout level and close, placing a midpoint label with percent difference; separately, a label at the VWAP end shows a computed stop price. Persistent variables track the active state and accumulators, resetting on new events after briefly extending old elements. Repaint risk from security calls is mitigated by confirmed bar gating or user opt-in.
Parameter Guide
Plateau Length (reserved for future, currently unused): Sets a length for potential plateau detection in extensions; default 3, minimum 1. Higher values would increase stability but are not active yet—leave at default to avoid tuning.
Line Width: Controls thickness of breakout, VWAP, and extension lines; default 2, range 1 to 5. Thicker lines improve visibility on busy charts but may obscure price action—use 1 for clean views, 3 or more for emphasis.
+Bars after next HTF event (finalize old, then delete): Extends old lines and labels by this many bars before deletion on new signals; default 20, minimum 0. Shorter extensions keep charts tidy but risk cutting visuals prematurely; longer aids review but builds clutter over time.
Evaluate label only on HTF close (prevents gray traps intrabar): When true, label updates wait for higher timeframe confirmation; default true. Enabling reduces intrabar flips for stabler signals, though it may delay feedback—disable for faster live trading at repaint cost.
Allow Repainting: Permits real-time security data without confirmation offset; default false. False ensures historical accuracy but lags live bars; true speeds updates but can repaint on HTF closes.
Timeframe Type: Chooses HTF method—Auto Timeframe (dynamic steps up), Multiplier (chart multiple), or Manual (fixed string); default Auto Timeframe. Auto adapts to chart scale for convenience; Multiplier suits custom scaling like 5 times current; Manual for precise like 1D on any chart.
Multiplier for Alternate Resolution: Scales chart timeframe when Multiplier type selected; default 5, minimum 1. Values near 1 mimic current resolution for subtle shifts; higher like 10 jumps to broader context, increasing signal rarity.
Manual Resolution: Direct timeframe string like 60 for 1H when Manual type; default 60. Match to trading horizon—shorter for swing, longer for positional—to balance frequency and reliability.
Show Extension 1: Toggles dotted line and delta percent label between breakout level and current close; default true. Disable to simplify for basic use, enable for precise momentum tracking.
Dotted Line Width: Thickness for Extension 1 line; default 2, range 1 to 5. Align with main Line Width for consistency.
Text Size: Size for delta percent label; options tiny, small, normal, large; default normal. Smaller reduces overlap on dense charts; larger aids glance reads.
Decimals for Δ%: Precision in percent change display; default 2, range 0 to 6. Fewer decimals speed reading; more suit low-volatility assets.
Positive Δ Color: Hue for upward percent changes; default lime. Choose contrasting for visibility.
Negative Δ Color: Hue for downward percent changes; default red. Pair with positive for quick polarity scan.
Dotted Line Color: Color for Extension 1 line; default gray. Neutral tones blend well; brighter for emphasis.
Background Transparency (0..100): Opacity for delta label background; default 90. Higher values fade for subtlety; lower solidifies for readability.
Show Extension 2: Toggles stop-loss label at VWAP end; default true. Turn off for entry focus only.
Stop Method: Percent from VWAP end or fixed ticks; options Percent, Ticks; default Percent. Percent scales with price levels; Ticks suits tick-based instruments.
Stop %: Distance as fraction of VWAP for Percent method; default 1.0, step 0.05, minimum 0.0. Tighter like 0.5 reduces risk but increases stops; wider like 2.0 allows breathing room.
Stop Ticks: Tick count offset for Ticks method; default 20, minimum 0. Adjust per asset volatility—fewer for tight control.
Price Decimals: Rounding for stop price text; default 4, range 0 to 10. Match syminfo.precision for clean display.
Text Size: Size for stop label; options tiny, small, normal, large; default normal. Scale to chart zoom.
Text Color: Foreground for stop text; default white. Ensure contrast with background.
Inherit VWAP Color (BG tint): Bases stop label background on VWAP hue; default true. True maintains theme; false allows custom black base.
BG Transparency (0..100): Opacity for stop label background; default 0. Zero for no tint; up to 100 for full fade.
Reading & Interpretation
Breakout lines appear green for bullish crosses or red for bearish, extending live until a new event finalizes them briefly then deletes. Labels start blank, updating to Bull Cont. or Bear Cont. in matching colors if holding the level, or gray Bull Trap/Bear Trap on reversal. VWAP dashes yellow for bulls, orange for bears, sloping with accumulated volume weight—deviations trigger faint red background warnings. Extension 1's dotted vertical shows at the last bar, with midpoint label green/red for positive/negative percent from breakout to close. Extension 2 places a left-aligned label at VWAP end with stop price and method note, tinted to VWAP for context.
Practical Workflows & Combinations
For trend following, enter long on green Bull Cont. labels above VWAP with higher highs confirmation, filtering via rising structure; short on red Bear Cont. below. Pair with volume surges or RSI above 50 for bulls to avoid traps. For exits, trail stops using the Extension 2 level, tightening on warnings or gray labels—aggressive on continuations, conservative post-trap. In multi-timeframe setups, use default Auto on 15m charts for 1H signals, scaling multiplier to 4 for daily context on hourly; test on forex/stocks where volume is reliable, avoiding low-liquidity assets.
Behavior, Constraints & Performance
Signals confirm on bar close with HTF gating when strict mode active, but live bars may update if repainting enabled—opt false for backtest fidelity, true for intraday speed. Security calls risk minor repaints on HTF closes, mitigated by confirmation offsets. Resources cap at 1000 bars back, 50 lines/labels total, with event prunes to stay under budgets—no loops, minimal arrays. Limits include VWAP lag in low-volume periods and dependency on accurate HTF data; gaps or holidays may skew anchors.
Sensible Defaults & Quick Tuning
Defaults suit 5m-1H charts on liquid assets: Auto HTF, no repaint, 1% stops. For choppy markets with excess signals, enable strict eval and bump multiplier to 10 for rarer triggers. If sluggish in trends, shorten extend bars to 10 and allow repainting for quicker visuals. On high-vol like crypto, widen stop % to 2.0 and use Ticks method; for stables like indices, tighten to 0.5% and keep Percent.
What this indicator is—and isn’t
This is a signal visualization layer for breakout confirmation and basic risk marking, best as a filter in discretionary setups. It isn’t a standalone system or predictive oracle—combine with price structure, news awareness, and sizing rules for real edges.
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 spots moments when the current chart's close price crosses a higher timeframe close, marking potential breakouts only when the current bar shows directional strength. It anchors a volume-weighted average price line from the breakout point to track trend health, updating labels to show if the move continues or reverses into a trap. Extensions add a dotted line linking the breakout level to the current close with percent change display, plus a stop-loss marker at the VWAP end. Signals gain robustness from higher timeframe confirmation and anti-repainting options, reducing noise in live bars compared to simple crossover tools.
Motivation: Why this design?
Traders often face false breakouts from intrabar wiggles on lower timeframes, especially without higher timeframe alignment, leading to whipsaws in volatile sessions. This design uses higher timeframe close as a stable reference for crossover detection, combined with anchored volume weighting to gauge sustained momentum. It addresses these by enforcing bar confirmation and directional filters, providing clearer entry validation and risk points without overcomplicating the chart.
What’s different vs. standard approaches?
Reference baseline
Standard crossover indicators like moving average crosses operate solely on the chart timeframe, ignoring higher timeframe context and lacking volume anchoring.
Architecture differences
- Higher timeframe data pulls via security calls with optional repainting control for stability.
- Anchored VWAP resets at each signal, accumulating from the breakout bar only.
- Label dynamics update in real-time for continuation checks, with extensions for visual delta and stop computation.
- Event-driven line finalization prunes old elements after a set bar extension.
Practical effect
Charts show persistent lines and labels that extend live but finalize cleanly on new events, avoiding clutter. This matters for spotting trap reversals early via label color shifts, and extensions provide quick risk visuals without manual calculations, improving decision speed in trend trades.
How it works (technical)
The indicator first determines a higher timeframe based on user selection, pulling its close price securely. It checks for crossovers or crossunders of the current close against this higher close, but only triggers on confirmed bars with matching directional opens and closes. On a valid event, a horizontal line and label mark the higher close level, while a dashed VWAP line starts accumulating typical price times volume from that bar onward. During the active phase, the breakout line extends to the current bar, the label repositions and updates text based on whether the current close holds above or below the level for bulls or bears. A background tint warns if the close deviates adversely from the current VWAP. Extensions draw a vertical dotted line at the last bar between the breakout level and close, placing a midpoint label with percent difference; separately, a label at the VWAP end shows a computed stop price. Persistent variables track the active state and accumulators, resetting on new events after briefly extending old elements. Repaint risk from security calls is mitigated by confirmed bar gating or user opt-in.
Parameter Guide
Plateau Length (reserved for future, currently unused): Sets a length for potential plateau detection in extensions; default 3, minimum 1. Higher values would increase stability but are not active yet—leave at default to avoid tuning.
Line Width: Controls thickness of breakout, VWAP, and extension lines; default 2, range 1 to 5. Thicker lines improve visibility on busy charts but may obscure price action—use 1 for clean views, 3 or more for emphasis.
+Bars after next HTF event (finalize old, then delete): Extends old lines and labels by this many bars before deletion on new signals; default 20, minimum 0. Shorter extensions keep charts tidy but risk cutting visuals prematurely; longer aids review but builds clutter over time.
Evaluate label only on HTF close (prevents gray traps intrabar): When true, label updates wait for higher timeframe confirmation; default true. Enabling reduces intrabar flips for stabler signals, though it may delay feedback—disable for faster live trading at repaint cost.
Allow Repainting: Permits real-time security data without confirmation offset; default false. False ensures historical accuracy but lags live bars; true speeds updates but can repaint on HTF closes.
Timeframe Type: Chooses HTF method—Auto Timeframe (dynamic steps up), Multiplier (chart multiple), or Manual (fixed string); default Auto Timeframe. Auto adapts to chart scale for convenience; Multiplier suits custom scaling like 5 times current; Manual for precise like 1D on any chart.
Multiplier for Alternate Resolution: Scales chart timeframe when Multiplier type selected; default 5, minimum 1. Values near 1 mimic current resolution for subtle shifts; higher like 10 jumps to broader context, increasing signal rarity.
Manual Resolution: Direct timeframe string like 60 for 1H when Manual type; default 60. Match to trading horizon—shorter for swing, longer for positional—to balance frequency and reliability.
Show Extension 1: Toggles dotted line and delta percent label between breakout level and current close; default true. Disable to simplify for basic use, enable for precise momentum tracking.
Dotted Line Width: Thickness for Extension 1 line; default 2, range 1 to 5. Align with main Line Width for consistency.
Text Size: Size for delta percent label; options tiny, small, normal, large; default normal. Smaller reduces overlap on dense charts; larger aids glance reads.
Decimals for Δ%: Precision in percent change display; default 2, range 0 to 6. Fewer decimals speed reading; more suit low-volatility assets.
Positive Δ Color: Hue for upward percent changes; default lime. Choose contrasting for visibility.
Negative Δ Color: Hue for downward percent changes; default red. Pair with positive for quick polarity scan.
Dotted Line Color: Color for Extension 1 line; default gray. Neutral tones blend well; brighter for emphasis.
Background Transparency (0..100): Opacity for delta label background; default 90. Higher values fade for subtlety; lower solidifies for readability.
Show Extension 2: Toggles stop-loss label at VWAP end; default true. Turn off for entry focus only.
Stop Method: Percent from VWAP end or fixed ticks; options Percent, Ticks; default Percent. Percent scales with price levels; Ticks suits tick-based instruments.
Stop %: Distance as fraction of VWAP for Percent method; default 1.0, step 0.05, minimum 0.0. Tighter like 0.5 reduces risk but increases stops; wider like 2.0 allows breathing room.
Stop Ticks: Tick count offset for Ticks method; default 20, minimum 0. Adjust per asset volatility—fewer for tight control.
Price Decimals: Rounding for stop price text; default 4, range 0 to 10. Match syminfo.precision for clean display.
Text Size: Size for stop label; options tiny, small, normal, large; default normal. Scale to chart zoom.
Text Color: Foreground for stop text; default white. Ensure contrast with background.
Inherit VWAP Color (BG tint): Bases stop label background on VWAP hue; default true. True maintains theme; false allows custom black base.
BG Transparency (0..100): Opacity for stop label background; default 0. Zero for no tint; up to 100 for full fade.
Reading & Interpretation
Breakout lines appear green for bullish crosses or red for bearish, extending live until a new event finalizes them briefly then deletes. Labels start blank, updating to Bull Cont. or Bear Cont. in matching colors if holding the level, or gray Bull Trap/Bear Trap on reversal. VWAP dashes yellow for bulls, orange for bears, sloping with accumulated volume weight—deviations trigger faint red background warnings. Extension 1's dotted vertical shows at the last bar, with midpoint label green/red for positive/negative percent from breakout to close. Extension 2 places a left-aligned label at VWAP end with stop price and method note, tinted to VWAP for context.
Practical Workflows & Combinations
For trend following, enter long on green Bull Cont. labels above VWAP with higher highs confirmation, filtering via rising structure; short on red Bear Cont. below. Pair with volume surges or RSI above 50 for bulls to avoid traps. For exits, trail stops using the Extension 2 level, tightening on warnings or gray labels—aggressive on continuations, conservative post-trap. In multi-timeframe setups, use default Auto on 15m charts for 1H signals, scaling multiplier to 4 for daily context on hourly; test on forex/stocks where volume is reliable, avoiding low-liquidity assets.
Behavior, Constraints & Performance
Signals confirm on bar close with HTF gating when strict mode active, but live bars may update if repainting enabled—opt false for backtest fidelity, true for intraday speed. Security calls risk minor repaints on HTF closes, mitigated by confirmation offsets. Resources cap at 1000 bars back, 50 lines/labels total, with event prunes to stay under budgets—no loops, minimal arrays. Limits include VWAP lag in low-volume periods and dependency on accurate HTF data; gaps or holidays may skew anchors.
Sensible Defaults & Quick Tuning
Defaults suit 5m-1H charts on liquid assets: Auto HTF, no repaint, 1% stops. For choppy markets with excess signals, enable strict eval and bump multiplier to 10 for rarer triggers. If sluggish in trends, shorten extend bars to 10 and allow repainting for quicker visuals. On high-vol like crypto, widen stop % to 2.0 and use Ticks method; for stables like indices, tighten to 0.5% and keep Percent.
What this indicator is—and isn’t
This is a signal visualization layer for breakout confirmation and basic risk marking, best as a filter in discretionary setups. It isn’t a standalone system or predictive oracle—combine with price structure, news awareness, and sizing rules for real edges.
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
Release Notes
Add some AlertsOpen-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.