OPEN-SOURCE SCRIPT

ATR Extension to SMA50

743
# How to Use the "ATR Extension to SMA50" Indicator
**Author:** CANSLIM Research by hkpress
**Platform:** TradingView

---

### Introduction

The **ATR Extension to SMA50** is a custom TradingView indicator designed to mathematically measure how "extended" or "stretched" a stock's price is from its 50-period Simple Moving Average (SMA50).

Instead of relying on fixed percentages, this tool uses the stock's own Average True Range (ATR) to calculate overbought or oversold conditions. This normalizes volatility, allowing you to use the exact same thresholds for a highly volatile tech stock and a slow-moving utility stock. It is an invaluable tool for risk management, identifying exhaustion points, and timing your entries or profit-taking.

---

### Section 1: How to Install on TradingView

Follow these steps to add the indicator to your TradingView charts:

1. **Open TradingView:** Log in to your account and open any chart.
2. **Open the Pine Editor:** At the very bottom of the charting screen, click on the tab labeled **Pine Editor**.
3. **Clear the Editor:** If there is any default code in the window, highlight all of it and delete it so you have a completely blank workspace.
4. **Paste the Code:** Copy the entire Pine Script code provided previously and paste it into the empty Pine Editor.
5. **Add to Chart:** Click the **Add to Chart** button located in the top right corner of the Pine Editor panel.
6. **Save the Script (Optional but Recommended):** Click **Save** in the Pine Editor, name it "ATR Extension to SMA50", so you can easily add it to other charts later from your "Indicators" menu under "My scripts".

---

### Section 2: Indicator Settings

Once the indicator is on your chart, you can adjust its parameters by hovering over the indicator's name in the bottom pane and clicking the **Settings (gear)** icon.

* **SMA Length (Default: 50):** The baseline moving average. 50 is the standard for intermediate-term trend following (favored by CANSLIM traders). You can adjust this to 20 for short-term trading or 200 for long-term investing.
* **ATR Length (Default: 14):** The lookback period for calculating the stock's volatility. 14 is the industry standard developed by J. Welles Wilder.

---

### Section 3: How to Read the Threshold Lines

The indicator plots as an oscillator with a baseline of `0` (which represents the exact price of the SMA50). Positive numbers indicate the stock is *above* the SMA50, and negative numbers indicate it is *below* it. The indicator line changes color dynamically based on the current extension.

#### Above the Mean (Uptrends)
* **0 to +1 ATR (Gray):** *Normal Base.* The stock is hugging its moving average. It is consolidating or moving quietly.
* **+2 ATR (Green):** *Healthy Trend.* The stock is trending up smoothly. A safe zone to hold.
* **+3 ATR (Yellow):** *Overextended.* The stock is starting to run hot. Breakout buyers entering here face higher risks of a pullback.
* **+4 ATR (Orange):** *Exhaustion Zone.* The stock is deeply extended. It is highly recommended to stop buying and consider protecting existing profits.
* **+5 ATR or up (Red):** *Extreme Parabolic.* A historically rare extension. Usually marks a blow-off top or climax run. Mean reversion (a sharp pullback) is highly probable.

#### Below the Mean (Downtrends)
* **0 to -1 ATR (Gray):** *Normal Pullback.* Slight weakness below the moving average.
* **-2 ATR (Green):** *Downtrend.* The stock is consistently weak.
* **-3 ATR (Yellow):** *Oversold.* The stock is getting hammered and may be due for a relief bounce.
* **-4 ATR (Orange):** *Capitulation Warning.* Deeply oversold. Sellers are exhausted.
* **-5 ATR or down (Red):** *Extreme Waterfall.* A rare panic-selling event. Often marks a tradable bottom or "V-shaped" recovery point.

---

### Section 4: Practical Trading Application

Here is how you can integrate this indicator into a trading system like CANSLIM:

**1. Avoid Chasing Breakouts**
If a stock breaks out of a base, but the ATR Extension reads **+3 or higher**, the breakout is considered "extended." It is mathematically safer to skip the trade and wait for the stock to build a new base or pull back closer to the SMA50 (the 0 to +1 zone).

**2. Defensive Profit Taking**
If you bought a stock correctly out of a base and it goes on a massive run, watch the ATR Extension. If it hits the **+4 (Orange) or +5 (Red)** levels, sell 20% to 50% of your position into the strength to lock in profits before the inevitable reversion to the mean.

**3. Spotting Climax Tops**
If a stock gaps up on massive volume after a long uptrend and the indicator hits **+5 ATR or up**, it is a classic "Climax Run" sell signal.

**4. Hunting for Snapback Bounces (Counter-Trend)**
If a fundamentally strong stock experiences a brutal sell-off due to market panic and hits the **-4 or -5 ATR or down** zone, aggressive traders can look for intraday reversal signals to buy the stock for a quick, violent snapback rally toward the SMA50.

---

*Disclaimer: This indicator is a mathematical tool designed to aid in technical analysis. It does not guarantee future performance or prevent losses. Always use proper risk management and stop losses when trading.*

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.