OPEN-SOURCE SCRIPT
Updated Sigmoid Transition Trailing Stop [LuxAlgo]

The Sigmoid Transition Trailing Stop indicator provides a dynamic risk management tool that utilizes a mathematical sigmoid function to smoothly adjust stop levels when price trends become overextended. Unlike traditional trailing stops that move linearly or remain static until a new high/low is formed, this script proactively "catches up" to price during periods of high momentum using a non-linear transition.
🔶 USAGE
The indicator functions as a trend-following stop-loss or take-profit level. When the price crosses the trailing stop, the trend direction flips, and a new stop is calculated based on the ATR-derived distance.
The unique behavior of this tool occurs during "Adjustment" phases. When the distance between the price and the trailing stop becomes too wide (exceeding the initial ATR multiplier), the script triggers a sigmoid transition. During this phase:
🔹 Visual Cues
🔶 DETAILS
The core of the script is the sigmoid function, which creates a natural-looking transition between two price levels. Mathematically, it maps a linear time input (bars passed) to an S-shaped curve between 0 and 1.
The logic ensures that the "trailing" property is never violated; even during a sigmoid transition, the stop level can only move in the direction of the trend (up for bullish, down for bearish). If the price moves against the trend during an adjustment, the stop will simply hold its level until the price moves favorably again or the adjustment period ends.
🔶 SETTINGS
🔹 General Settings
🔶 USAGE
The indicator functions as a trend-following stop-loss or take-profit level. When the price crosses the trailing stop, the trend direction flips, and a new stop is calculated based on the ATR-derived distance.
The unique behavior of this tool occurs during "Adjustment" phases. When the distance between the price and the trailing stop becomes too wide (exceeding the initial ATR multiplier), the script triggers a sigmoid transition. During this phase:
- The trailing stop line becomes solid (0% transparency) to indicate an active adjustment.
- The stop level moves towards the price following an S-curve, providing a smooth acceleration and deceleration of the stop level.
- The adjustment concludes once the sigmoid duration is reached or if the stop gets too close to the price (defined by the Min Distance setting).
🔹 Visual Cues
- Green Line/Fill: Indicates a bullish trend where the stop is below the price.
- Red Line/Fill: Indicates a bearish trend where the stop is above the price.
- Solid Line: The sigmoid adjustment is currently active, moving the stop closer to price.
- Transparent Line: The stop is in its standard state, maintaining its level or trailing highs/lows.
🔶 DETAILS
The core of the script is the sigmoid function, which creates a natural-looking transition between two price levels. Mathematically, it maps a linear time input (bars passed) to an S-shaped curve between 0 and 1.
The logic ensures that the "trailing" property is never violated; even during a sigmoid transition, the stop level can only move in the direction of the trend (up for bullish, down for bearish). If the price moves against the trend during an adjustment, the stop will simply hold its level until the price moves favorably again or the adjustment period ends.
🔶 SETTINGS
🔹 General Settings
- ATR Length: The lookback period used to calculate the Average True Range, which determines the volatility-based distance of the stop.
- ATR Multiplier: The base distance (in ATR units) used when the trend first flips.
- Sigmoid Length (Bars): The number of bars over which the sigmoid transition occurs once triggered.
- Sigmoid Amplitude (ATR Units): The maximum distance the stop is allowed to travel toward the price during an adjustment phase.
- Min Distance (ATR Units): A safety buffer that prevents the sigmoid adjustment from moving the stop too close to the current price, preventing premature exits.
Release Notes
- Included style settingsOpen-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
All content & scripts provided by LuxAlgo are for educational purposes only and are not financial advice.
Disclaimer
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
All content & scripts provided by LuxAlgo are for educational purposes only and are not financial advice.
Disclaimer
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.