OPEN-SOURCE SCRIPT
Supertrend Scalping

This Pine Script indicator called “Supertrend Scalping” is designed for scalping strategies and is built around the Supertrend indicator, enhanced with a complete trade management system including multiple Take Profit (TP) levels and a dynamic Stop Loss (SL).
The script begins by calculating the ATR (Average True Range), which measures market volatility. The user can choose between the standard ATR (RMA) or a simple moving average version (SMA). This ATR is then used to construct the Supertrend bands by adding and subtracting a multiple of the ATR from a price source (by default, hl2). These bands adjust dynamically and define the trend: when price breaks above the upper band, the trend turns bullish; when it breaks below the lower band, the trend becomes bearish.
Trading signals are generated when the trend changes direction. A BUY (LONG) signal appears when the trend shifts from bearish to bullish, while a SELL (SHORT) signal appears when it shifts from bullish to bearish. At each new signal, the script initializes a virtual trade using the current closing price as the entry point.
The core strength of this script lies in its trade management system. It automatically calculates three Take Profit levels (TP1, TP2, TP3) and an initial Stop Loss, all based on configurable ATR multiples. These levels are displayed on the chart using colored lines and labels. The script then continuously monitors price action to detect when these levels are reached.
When a Take Profit level is hit, it is visually removed. If TP1 is reached, the Stop Loss can be moved to the entry price (break-even). If TP2 is reached, the Stop Loss is moved up to the TP1 level. This creates a smart trailing stop mechanism that progressively locks in profits. If either TP3 or the Stop Loss is hit, the trade is fully closed and all visual elements are cleared.
Additionally, the script updates label positions in real time so they follow the current bar, and it highlights the active trend with a colored background (green for bullish, red for bearish). It also includes alert conditions for entry signals as well as TP and SL hits.
In summary, this indicator goes beyond simple signal generation by offering a complete scalping framework, combining entry signals, structured profit targets, risk management, and volatility-based adaptability.
The script begins by calculating the ATR (Average True Range), which measures market volatility. The user can choose between the standard ATR (RMA) or a simple moving average version (SMA). This ATR is then used to construct the Supertrend bands by adding and subtracting a multiple of the ATR from a price source (by default, hl2). These bands adjust dynamically and define the trend: when price breaks above the upper band, the trend turns bullish; when it breaks below the lower band, the trend becomes bearish.
Trading signals are generated when the trend changes direction. A BUY (LONG) signal appears when the trend shifts from bearish to bullish, while a SELL (SHORT) signal appears when it shifts from bullish to bearish. At each new signal, the script initializes a virtual trade using the current closing price as the entry point.
The core strength of this script lies in its trade management system. It automatically calculates three Take Profit levels (TP1, TP2, TP3) and an initial Stop Loss, all based on configurable ATR multiples. These levels are displayed on the chart using colored lines and labels. The script then continuously monitors price action to detect when these levels are reached.
When a Take Profit level is hit, it is visually removed. If TP1 is reached, the Stop Loss can be moved to the entry price (break-even). If TP2 is reached, the Stop Loss is moved up to the TP1 level. This creates a smart trailing stop mechanism that progressively locks in profits. If either TP3 or the Stop Loss is hit, the trade is fully closed and all visual elements are cleared.
Additionally, the script updates label positions in real time so they follow the current bar, and it highlights the active trend with a colored background (green for bullish, red for bearish). It also includes alert conditions for entry signals as well as TP and SL hits.
In summary, this indicator goes beyond simple signal generation by offering a complete scalping framework, combining entry signals, structured profit targets, risk management, and volatility-based adaptability.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。