Skip to main content

ATRTS

Info

Average True Range (ATR): ATR is a technical analysis indicator that measures market volatility by decomposing the entire range of an asset price for that period. It does not indicate price trend, only the degree of price volatility.

The Average True Range (ATR) indicator measures market volatility by considering the high, low, and closing prices over a specified period (typically 14 days).

Traders use ATR to gauge how large price swings are. Higher ATR values indicate more volatility; lower values indicate less.

The ATRTS strategy uses ATR to set dynamic trailing stops, automating buy and sell signals based on volatility. A configurable multiplier, ATRX, is applied to the ATR value to calculate upper and lower threshold lines. The resulting values are the strategy’s ATR long (upper limit for buys) and ATR short (lower limit for sells). Because ATR does not indicate direction, consider adding a momentum indicator (like RSI) for confirmation.

Trailing Stop Calculation

The strategy calculates upper and lower trailing stop levels using the ATR value and the ATRX multiplier:

  • ATR short (lower limit for sells) is calculated based on subtracting the (ATR * ATRX) value from the bid price.
  • ATR long (upper limit for buys) is calculated based on adding the (ATR * ATRX) value to the ask price.

How It Works

Buy Conditions:

A buy order is triggered when the current ask price crosses above the calculated ATR long limit.

Sell Conditions:

A sell order is triggered when the current bid price crosses below the calculated ATR short limit, provided the price is above break-even (if GAIN is > 0).

Trading Example

ATRTS strategy example showing volatility-based trading with ATR indicator

Example of potential ATRTS strategy performance. [_Details and settings](https://www.tradingview.com/chart/BQXBTC/CGLIN3ce-ATRTS-Gunbot-trading-strategy/ )_

ATRTS Strategy Settings

Buy Settings

LabelConfig ParameterDefault ValueDetailed Description
Buy enabledBUY_ENABLEDtrueEnable or disable buy (long) orders for the strategy.

Sell Settings

LabelConfig ParameterDefault ValueDetailed Description
Sell enabledSELL_ENABLEDtrueEnable or disable sell (short) orders for the strategy.
GainGAIN1Minimum profit percentage above break-even required to place a sell order. If set to 0, sells can occur based on ATR signal alone, potentially at a loss.
Stop limitSTOP_LIMIT99Stop-loss threshold. If the price drops by this percentage below break-even, a sell order is triggered. A high value like 99 effectively disables it.
Count sellCOUNT_SELL9999Disables trading for the pair after the specified number of sell orders.

Indicators

LabelConfig ParameterDefault ValueDetailed Description
PeriodPERIOD15Candlestick period (e.g., 15 minutes) used for indicator calculations, including ATR. Ensure the value is supported by your exchange.
ATRxATRX0.5Multiplier applied to ATR to set the `ATR long` (buy) and `ATR short` (sell) thresholds.
ATR periodATR_PERIOD14The number of historical periods (candles) used to calculate the Average True Range (ATR).

Overview of Effects on Different Order Types

Config ParameterAffected Order TypesNot Affected Order Types
Buy EnabledStrategy buy, DCA buy, RT buy, RT buybackStrategy sell, Stop limit, Close, RT sell
Sell EnabledStrategy sell, Stop limit, RT sellStrategy buy, RT buy, RT buyback, Close, DCA buy
GainStrategy sellStrategy buy, RT buy, RT buyback, RT sell, Close, DCA buy, Stop limit
PeriodStrategy sell, Strategy buy, DCA buy (when using an indicator)RT buy, RT buyback, RT sell, Close, Stop limit
ATRxStrategy sell, Strategy buyRT buy, RT buyback, RT sell, Close, Stop limit, DCA buy
ATR PeriodStrategy sell, Strategy buyRT buy, RT buyback, RT sell, Close, Stop limit, DCA buy