BACK TO CLAUDE SKILLS
◈
calculate_atr
IndicatorsATRVolatility
INSTALLATION
$python -c "exec(open('calculate_atr.py').read())"
#or paste directly into your Claude Code terminal
[ ABOUT ]
Computes the Average True Range by first calculating the True Range for each bar (the maximum of: high−low, |high−prev_close|, |low−prev_close|), then averaging the last `period` values. ATR measures volatility in absolute price terms rather than percentages, making it suitable for position sizing and stop loss placement.
For stop loss calculation, a common rule of thumb is to place stops at 1.5× to 2× ATR below the entry price for long trades. This approach automatically widens stops during high-volatility conditions and tightens them during calm markets, rather than using a fixed percentage that may be too tight or too wide depending on current market conditions.
[ USAGE EXAMPLE ]
[ FULL CODE ]
[ METADATA ]
CategoryIndicators
ComplexityBeginner
LanguagePython 3.10+
TagsATR, Volatility
[ ASK CLAUDE ]
Ask AI about this skill before installing it.