OPEN-SOURCE SCRIPT
OneShot with Alerts

The One Shot with Alerts indicator is an advanced price action tool based on the Average True Range (ATR) concept.
It automatically constructs a three-line ATR channel consisting of an upper boundary (ATR Top), a lower boundary (ATR Bottom), and a central equilibrium line (ATR Midline).
This setup allows traders to clearly visualize volatility-driven price ranges and detect momentum reversals when price crosses the median level.
⚙️ Core Logic
ATR Channel Construction
The indicator calculates the ATR over a user-defined period (atrLen), defaulting to 200 bars.
It then determines two fixed levels from the previous candle’s close and ATR value:
ATR Bottom = Close[1] − ATR × Multiplier (Bottom)
ATR Top = Close[1] + ATR × Multiplier (Top)
A Midline is automatically derived as the midpoint between the two.
Using the ATR from the previous bar ensures that the lines remain static during the current candle, giving traders stable reference zones instead of constantly shifting levels.
Crossover Detection
The midline acts as the decision boundary.
When the current price crosses above the midline → a BUY signal is generated.
When the current price crosses below the midline → a SELL signal is triggered.
Only one signal can appear per bar, and it will always be the opposite of the previous one — avoiding multiple conflicting signals in flat markets.
Signal Labeling and Visualization
Each signal is displayed directly on the chart:
BUY labels appear below the candle with an upward pointer.
SELL labels appear above the candle with a downward pointer.
Labels also display the exact price at which the crossover occurred, formatted for easy reading (e.g., BUY 102 417).
Labels are positioned with a configurable offset (labelOffset) based on ATR size.
ATR Channel Visualization
The ATR Top and Bottom are drawn in orange, while the Midline is shown in yellow for clarity.
The area between Top and Bottom is softly shaded to visually represent the current volatility range.
This helps traders instantly identify whether the market is trading in a narrow consolidation or a wide volatile phase.
🔔 Alerts and Trading Use
While the script doesn’t include built-in alerts by default, it can be easily modified to trigger alerts on each signal event.
The BUY/SELL logic is suitable for:
Reversal trading strategies, entering trades at momentum shifts.
Trend-following confirmations, where the midline serves as a bias filter.
Scalping setups, where price re-enters the channel from one side to another.
Because the lines are based on the previous bar’s ATR, they stay fixed throughout the bar, giving traders clean, non-repainting entry conditions.
💡 Key Benefits
✅ Fixed ATR-based channel — no line jittering on live candles
✅ Clear entry and exit signals with precise price values
✅ Non-repainting logic
✅ Works on any timeframe or asset
✅ Fully customizable multipliers and offsets
📊 Typical Use Case
Traders can use this indicator to:
Identify momentum reversals when the price crosses the ATR Midline.
Combine it with other indicators (RSI, MACD, or volume) for signal confirmation.
Use the ATR channel as dynamic support/resistance zones for trailing stops or entries.
It automatically constructs a three-line ATR channel consisting of an upper boundary (ATR Top), a lower boundary (ATR Bottom), and a central equilibrium line (ATR Midline).
This setup allows traders to clearly visualize volatility-driven price ranges and detect momentum reversals when price crosses the median level.
⚙️ Core Logic
ATR Channel Construction
The indicator calculates the ATR over a user-defined period (atrLen), defaulting to 200 bars.
It then determines two fixed levels from the previous candle’s close and ATR value:
ATR Bottom = Close[1] − ATR × Multiplier (Bottom)
ATR Top = Close[1] + ATR × Multiplier (Top)
A Midline is automatically derived as the midpoint between the two.
Using the ATR from the previous bar ensures that the lines remain static during the current candle, giving traders stable reference zones instead of constantly shifting levels.
Crossover Detection
The midline acts as the decision boundary.
When the current price crosses above the midline → a BUY signal is generated.
When the current price crosses below the midline → a SELL signal is triggered.
Only one signal can appear per bar, and it will always be the opposite of the previous one — avoiding multiple conflicting signals in flat markets.
Signal Labeling and Visualization
Each signal is displayed directly on the chart:
BUY labels appear below the candle with an upward pointer.
SELL labels appear above the candle with a downward pointer.
Labels also display the exact price at which the crossover occurred, formatted for easy reading (e.g., BUY 102 417).
Labels are positioned with a configurable offset (labelOffset) based on ATR size.
ATR Channel Visualization
The ATR Top and Bottom are drawn in orange, while the Midline is shown in yellow for clarity.
The area between Top and Bottom is softly shaded to visually represent the current volatility range.
This helps traders instantly identify whether the market is trading in a narrow consolidation or a wide volatile phase.
🔔 Alerts and Trading Use
While the script doesn’t include built-in alerts by default, it can be easily modified to trigger alerts on each signal event.
The BUY/SELL logic is suitable for:
Reversal trading strategies, entering trades at momentum shifts.
Trend-following confirmations, where the midline serves as a bias filter.
Scalping setups, where price re-enters the channel from one side to another.
Because the lines are based on the previous bar’s ATR, they stay fixed throughout the bar, giving traders clean, non-repainting entry conditions.
💡 Key Benefits
✅ Fixed ATR-based channel — no line jittering on live candles
✅ Clear entry and exit signals with precise price values
✅ Non-repainting logic
✅ Works on any timeframe or asset
✅ Fully customizable multipliers and offsets
📊 Typical Use Case
Traders can use this indicator to:
Identify momentum reversals when the price crosses the ATR Midline.
Combine it with other indicators (RSI, MACD, or volume) for signal confirmation.
Use the ATR channel as dynamic support/resistance zones for trailing stops or entries.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.