trailing stop loss
May 14, 2019

The Trailing Stop Loss indicator provides automated dynamic support and resistance levels to help traders manage exit points and identify trend reversals through volatility-adjusted price tracking.
Usage
The Usage section describes how the script can be used to manage risk and identify potential trend shifts. Traders typically use this tool to define exit criteria for active positions or to gauge the strength of a current trend.
- Long Positions: When holding a long position, the green line represents the trailing stop level. A price close below this level may indicate a trend reversal or an optimal exit point to preserve capital.
- Short Positions: When holding a short position, the red line represents the trailing stop level. A price close above this level suggests that the downward momentum may be fading, signaling a potential exit.
- Trend Identification: The distance between the price and the trailing stops can indicate market volatility; a tightening stop indicates lower volatility or a consolidating trend, while a wider stop accounts for higher market swings.
Details
The Trailing Stop Loss is constructed using a combination of the Average True Range (ATR) and lookback periods. The script calculates the volatility buffer by multiplying the ATR (using a fixed length of 5) by the user-defined Multiplier.
For long positions, the indicator tracks the highest point the price (minus the volatility buffer) has reached over the specified Length. For short positions, it tracks the lowest point the price (plus the volatility buffer) has reached over the same period. This ensures the stop loss only moves in the direction of the trade or remains stationary during retracements, preventing premature exits during minor fluctuations. This version is refactored for visual clarity and includes optimized alert conditions for price crossovers.
Settings
General Settings
- Length: Defines the lookback period (1 to 200) used to find the highest or lowest price points for the trailing calculation.
- Multiplier: A sensitivity factor that determines how many multiples of the ATR the stop loss should be placed from the price. A higher multiplier provides a wider stop, while a lower multiplier makes the stop more reactive to price changes.
FAQ
How does the Multiplier affect the indicator?
A higher multiplier increases the distance between the price and the stop loss, allowing for more market noise. A lower multiplier tightens the stop, which can be useful for scalping but may result in more frequent stop-outs.
Can I use this for automated alerts?
Yes, the script includes built-in alert conditions that trigger when the price crosses under the long trailing stop or crosses over the short trailing stop.
How can I access this tool?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.