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.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.