How It Works: Parameters : ATR Period : The period for calculating ATR (default is 14). Stop Loss Multiplier : The ATR multiplier for calculating the stop-loss (default is 1.5). Take Profit Multiplier : The ATR multiplier for calculating the take-profit (default is 2.0). ATR Calculation : The built-in ta.atr() function is used to calculate the Average True Range. Stop-Loss Levels : For long positions: the current price minus the ATR value multiplied by the multiplier. For short positions: the current price plus the ATR value multiplied by the multiplier. Take-Profit Levels : For long positions: the current price plus the ATR value multiplied by the multiplier. For short positions: the current price minus the ATR value multiplied by the multiplier. Visualization : Green line — Stop-loss level for long positions. Red line — Stop-loss level for short positions. Teal line — Take-profit level for long positions. Orange line — Take-profit level for short positions. Text labels "Long SL", "Short SL", "Long TP", and "Short TP" are added for clarity.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publications is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.