OPEN-SOURCE SCRIPT

OneShot with Alerts

154
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.

Declinazione di responsabilità

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.