OPEN-SOURCE SCRIPT
Breaking Ray [vganesh]

Breaking Ray [vganesh] — Anchor a Level, Watch It Break
## Overview
Breaking Ray [vganesh] anchors a horizontal ray to a single candle you click on — its top, bottom, or both. The ray extends forward indefinitely, exactly like TradingView's built-in Ray drawing tool, until price actually breaks it. At that moment it freezes into a fixed line segment running from the anchor candle to the candle that broke it, so your chart keeps a permanent, uncluttered record of exactly when and where a level gave way.
It works the same way the built-in Anchored VWAP does: add the indicator, click the candle you want to anchor to, and you're done. Want to track several candles at once? Add another instance of the indicator for each one — every instance is independent.
## How It Works
- **Anchoring**: click any candle (or reposition later via the target icon in Settings) to set the ray's origin. You choose whether it originates from that candle's high, low, or both.
- **Breaking**: each bar, the script checks whether price has broken the level (wick or close, your choice). The instant it does, the ray stops extending and locks into a plain line segment — a visual record of exactly how long that level held.
- **Multi-timeframe aware**: set "Anchor Candle's Timeframe" to the timeframe you clicked on (e.g. "D" for a Daily candle), and the ray will show the correct level and starting point no matter what timeframe you switch the chart to afterward.
## Key Features
- Click-to-anchor UX — no manual price/time entry required
- Draw from the candle's Top, Bottom, or Both
- Break detection by wick touch or candle close
- Optional halo line and a price label (Left / Center / Right anchored) so the ray stays legible even on busy, lower-timeframe charts
- Broken rays can be kept as a permanent segment or discarded entirely
- Built-in alerts, including a dynamic message with the ticker, which side broke, and the exact price
- On-chart diagnostics (an optional debug label) if a ray isn't behaving as expected
## How To Use
1. Add the indicator to your chart.
2. Click the candle you want to anchor to when prompted.
3. If you plan to view the ray on a timeframe other than the one you clicked on, set "Anchor Candle's Timeframe" to match (e.g. "D", "4H").
4. Choose Top, Bottom, or Both under "Draw Ray From".
5. Adjust style, break sensitivity, and label settings to taste.
6. Repeat with a new indicator instance for each additional candle you want to track.
## Alerts
Create an alert on this indicator with the condition **"Any alert() function call"** and set the alert's Message field to `{{alert_message}}` to receive the dynamic message: `{{ticker}} Top ray broken at <price>` (or Bottom). A generic "Ray Broken" condition is also available for a simple yes/no trigger.
## Notes
- One indicator instance tracks one anchor candle by design — this keeps each ray independently configurable (its own color, break rule, timeframe, etc.).
- The ray's exact starting bar is timeframe-dependent: it points to the specific candle where the high/low actually printed, so the same anchor can look slightly different in position (never in price) depending on what timeframe you're viewing.
## Disclaimer
This script is provided for informational and educational purposes only. It does not constitute financial advice, and past levels holding or breaking are not indicative of future price behavior. Always do your own research and manage risk appropriately.
## Overview
Breaking Ray [vganesh] anchors a horizontal ray to a single candle you click on — its top, bottom, or both. The ray extends forward indefinitely, exactly like TradingView's built-in Ray drawing tool, until price actually breaks it. At that moment it freezes into a fixed line segment running from the anchor candle to the candle that broke it, so your chart keeps a permanent, uncluttered record of exactly when and where a level gave way.
It works the same way the built-in Anchored VWAP does: add the indicator, click the candle you want to anchor to, and you're done. Want to track several candles at once? Add another instance of the indicator for each one — every instance is independent.
## How It Works
- **Anchoring**: click any candle (or reposition later via the target icon in Settings) to set the ray's origin. You choose whether it originates from that candle's high, low, or both.
- **Breaking**: each bar, the script checks whether price has broken the level (wick or close, your choice). The instant it does, the ray stops extending and locks into a plain line segment — a visual record of exactly how long that level held.
- **Multi-timeframe aware**: set "Anchor Candle's Timeframe" to the timeframe you clicked on (e.g. "D" for a Daily candle), and the ray will show the correct level and starting point no matter what timeframe you switch the chart to afterward.
## Key Features
- Click-to-anchor UX — no manual price/time entry required
- Draw from the candle's Top, Bottom, or Both
- Break detection by wick touch or candle close
- Optional halo line and a price label (Left / Center / Right anchored) so the ray stays legible even on busy, lower-timeframe charts
- Broken rays can be kept as a permanent segment or discarded entirely
- Built-in alerts, including a dynamic message with the ticker, which side broke, and the exact price
- On-chart diagnostics (an optional debug label) if a ray isn't behaving as expected
## How To Use
1. Add the indicator to your chart.
2. Click the candle you want to anchor to when prompted.
3. If you plan to view the ray on a timeframe other than the one you clicked on, set "Anchor Candle's Timeframe" to match (e.g. "D", "4H").
4. Choose Top, Bottom, or Both under "Draw Ray From".
5. Adjust style, break sensitivity, and label settings to taste.
6. Repeat with a new indicator instance for each additional candle you want to track.
## Alerts
Create an alert on this indicator with the condition **"Any alert() function call"** and set the alert's Message field to `{{alert_message}}` to receive the dynamic message: `{{ticker}} Top ray broken at <price>` (or Bottom). A generic "Ray Broken" condition is also available for a simple yes/no trigger.
## Notes
- One indicator instance tracks one anchor candle by design — this keeps each ray independently configurable (its own color, break rule, timeframe, etc.).
- The ray's exact starting bar is timeframe-dependent: it points to the specific candle where the high/low actually printed, so the same anchor can look slightly different in position (never in price) depending on what timeframe you're viewing.
## Disclaimer
This script is provided for informational and educational purposes only. It does not constitute financial advice, and past levels holding or breaking are not indicative of future price behavior. Always do your own research and manage risk appropriately.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.