What Is Average True Range (ATR)?
The Average True Range (ATR) is a technical analysis indicator originally developed by J. Welles Wilder in 1978 for stock market analysis. It measures market volatility by calculating the moving average of true price ranges over a specified period (typically 14 days). Often referred to as a "reversal indicator," ATR helps traders:
- Identify optimal entry/exit points
- Allocate capital efficiently
- Dynamically adjust stop-loss levels
- Manage position sizing
👉 Discover how ATR transforms volatility into actionable insights
How to Use the ATR Indicator
1. Strategic Capital Allocation
When trading multiple assets, equal fund distribution often overlooks volatility differences. ATR-based allocation ensures each asset's risk exposure aligns with portfolio goals.
Implementation Example (for a $1M portfolio):
| Asset | ATR Value | Contract Multiplier | Position Size Calculation | Final Position |
|-------------|-----------|---------------------|---------------------------|----------------|
| SHFE.au1912 | $6.6 | 1,000 | $10,000 ÷ ($6.6×1,000) | 1.52 → 1 lot |
| DCE.i2001 | $27.3 | 100 | $10,000 ÷ ($27.3×100) | 3.66 → 3 lots |
This method equalizes the impact of each asset's volatility on the portfolio.
2. Dynamic Stop-Loss Adjustment
Fixed-percentage stop-losses fail to account for asset volatility. ATR-tailored stops adapt to market conditions:
Gold Futures (SHFE.au1912)
- Entry: $352.5
- ATR (n): $6.6
- Stop-Loss: $352.5 - (2 × $6.6) = $339.3
if position.pos_long > 0:
if current_price <= entry_price - 2*n:
print("Trigger stop-loss")
target_pos.set_target_volume(0)3. Position Sizing Optimization
ATR automatically adjusts position sizes when volatility changes. For example, if DCE.i2001's ATR drops from $27.3 to $20:
- New Position: $10,000 ÷ ($20×100) = 5 lots
- Action: Buy 2 additional lots (from 3→5)
Calculating ATR: The Formula
True Range (TR) = Maximum of:
- Current High - Current Low
- |Current High - Previous Close|
- |Previous Close - Current Low|
- ATR = 14-day SMA of TR
Python Implementation:
from tqsdk.ta import ATR
klines = api.get_kline_serial("SHFE.au1912", 86400)
atr_data = ATR(klines, 14)
print("TR Values:", atr_data.tr)
print("ATR Values:", atr_data.atr)ATR Trading Strategy Example
Environment: Tianqin Quantitative Platform
Rules:
- Buy 1 lot SHFE.au1912 at $352.5
- Add 1 lot if price rises to $352.5 + 0.5n ($355.8)
- Full exit if price falls to $352.5 - 2n ($339.3)
if quote.last_price >= entry_price + 0.5*n:
target_pos.set_target_volume(2) # Add position
elif quote.last_price <= entry_price - 2*n:
target_pos.set_target_volume(0) # Stop-loss👉 Master ATR strategies with professional trading tools
FAQ
Q: Why use 14 days for ATR calculation?
A: Wilder's research showed 14 days optimally balances responsiveness and noise reduction.
Q: Can ATR predict price direction?
A: No—it quantifies volatility only. Combine with trend indicators for directional bias.
Q: How does ATR compare to standard deviation?
A: Both measure volatility, but ATR accounts for gaps between sessions, making it preferable for discontinuous markets.
Q: What's the ideal ATR value for trading?
A: Context-dependent. Compare current ATR to historical ranges for perspective.
Q: Should ATR be normalized for different assets?
A: Yes. Divide ATR by closing price to compare volatility across instruments.
Q: How do Turtle Traders use ATR?
A: They size positions as 1% of capital per 1 ATR risk, and set stops at 2×ATR below entry.
Note: All examples are for educational purposes. Past performance doesn’t guarantee future results.