OPEN-SOURCE SCRIPT
ATR-Based SL/TP Strategy

This Pine Script strategy demonstrates how to use the Average True Range (ATR) as a dynamic method for setting stop loss and take profit levels. It is provided as an*educational resource to help traders understand how volatility-based exits can be implemented in automated strategies.
Full credit for the source code to Intertia
How It Works:
1. Entry Logic:
- The strategy uses the Relative Strength Index (RSI) to identify potential entry points.
- A long trade is triggered when the RSI crosses above the oversold threshold.
- A short trade is triggered when the RSI crosses below the overbought threshold.
2. Exit Logic (ATR-Based):
- Once in a trade, the strategy calculates the Average True Range (ATR) to determine a stop loss and take profit based on recent price volatility.
- For long trades, the stop loss is set below the entry price by a multiple of the ATR, and the take profit is set above the entry by a larger multiple.
- For short trades, the stop loss is above and the take profit is below the entry, also based on ATR multipliers.
- This ensures exit levels adjust automatically depending on current market volatility.
3. Customizable Parameters:
- Traders can adjust the ATR length, stop loss multiplier, and take profit multiplier to match their risk preferences.
- RSI settings (period, overbought, and oversold levels) are also configurable to adapt to different market conditions.
Visualization:
- ATR is calculated but hidden by default from the chart view for a cleaner layout.
- Entry points are optionally marked with labels for easier debugging and educational review.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.