All indicators

ATR Trailing Stoploss Strategy

Sep 11, 2020

Static chart image
SignalsTrailing-StopVolatility

The ATR Trailing Stoploss Strategy tool automates trend following and risk management by generating buy and sell signals based on volatility-adjusted price levels. It provides a systematic approach to entering and exiting positions by tracking price movements relative to a dynamic stop-loss line.

Usage

The Usage section describes how the script can be used for trend identification and trade execution. The strategy identifies potential entries when price action crosses the calculated trailing stop level.

  • Long Entry: A buy signal is generated when the closing price crosses above the trailing stop line.
  • Short Entry: A sell signal is generated when the closing price crosses below the trailing stop line.

The indicator is versatile across various timeframes; however, using longer timeframes typically results in higher success rates and fewer false signals compared to lower timeframes, which generate more frequent signals due to market noise. The default configuration uses an ATR Period of 5, an HHV Period of 10, and a Multiplier of 2.5, which balances sensitivity with trend retention.

Details

The script's execution is based on the relationship between price volatility and historical highs. It calculates the Average True Range (ATR) to measure market volatility and subtracts a weighted version of this value (determined by the Multiplier) from the price.

The core logic utilizes the Highest High Value (HHV) over a specified period to establish a trailing floor. Specifically, it tracks the highest value of high - (multiplier * ATR). This ensures that the trailing stop moves upward during bullish momentum but remains at a fixed level when the price stalls or pulls back, provided the price remains above the stop level. The script uses the ta.valuewhen function to maintain the previous stop level until a new high in the calculation is confirmed, creating the "stepping" visual effect common in trailing stop-loss systems.

Settings

  • ATR Period: Defines the lookback period used to calculate the Average True Range for volatility measurement.
  • HHV Period: Determines the lookback window for identifying the highest high value used in the trailing stop calculation.
  • Multiplier: A coefficient applied to the ATR value to determine the distance between the price and the trailing stop line.
  • Barcolor: A toggle to enable or disable price candle coloring based on the current trend direction (green for bullish, red for bearish).

FAQ

How do I adjust the sensitivity of the signals? You can adjust the Multiplier and the ATR Period settings. A lower Multiplier or ATR Period will make the trailing stop tighter and more sensitive to price changes, resulting in more frequent signals, while higher values will result in a wider stop that filters out minor fluctuations.

What market conditions are best for this strategy? This strategy performs most effectively in trending markets. Because it is a trailing stop-loss system, it excels at capturing large moves during sustained trends but may experience "whipsaws" or frequent losing trades during sideways or range-bound market conditions.

How can I access the ATR Trailing Stoploss Strategy? 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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.