To calculate the Average True Range (ATR), we first need to calculate the true range of each candle period. True Range takes into account the most current period high/low range as well as the previous period close if necessary.
There are three calculation which need to be completed and then compared against each other.
The True Range is the largest of the following:
The Current Period High minus (-) Current Period Low
The Absolute Value (abs) of the Current Period High minus (-) The Previous Period Close
The Absolute Value (abs) of the Current Period Low minus (-) The Previous Period Close
The ATR is an Exponential Moving Average (default EMA, can be SMA, HMA, DEMA) of the True Range.
Use Tradingview to visualize this indicator.
View on Tradingview
ATRPERCENTAGE_indicator = EMA/SMA/HMA/DEMA
ATRPERCENTAGE_candle_period = 3600
ATRPERCENTAGE_length = 14
ATRPERCENTAGE_offset = 1
# Buy if the ATR is less than 1.5.
DEFAULT_A_buy_strategy = ATRPERCENTAGE
DEFAULT_A_buy_value = 1.5
#Sell if the ATR is more than 3
DEFAULT_A_sell_strategy = ATRPERCENTAGE
DEFAULT_A_sell_value = 3
# You can also buy when the volatility is higher than a certain threshold by changing the buy strategy direction.
# Buy if the ATR is 2 or more.
DEFAULT_A_buy_strategy = ATRPERCENTAGE
DEFAULT_A_buy_value = 2
DEFAULT_A_buy_strategy_direction = UP
# Buy if the ATR is less than 1.5.
DEFAULT_DCA_A_buy_strategy = ATRPERCENTAGE
DEFAULT_DCA_A_buy_value = 1.5
#Sell if the ATR is more than 3
DEFAULT_DCA_A_sell_strategy = ATRPERCENTAGE
DEFAULT_DCA_A_sell_value = 3
# You can also buy when the volatility is higher than a certain threshold by changing the buy strategy direction.
# Buy if the ATR is 2 or more.
DEFAULT_DCA_A_buy_strategy = ATRPERCENTAGE
DEFAULT_DCA_A_buy_value = 2
DEFAULT_DCA_A_buy_strategy_direction = UP
ATRPERCENTAGE_indicator = EMA
ATRPERCENTAGE_candle_period = 3600
ATRPERCENTAGE_length = 14
ATRPERCENTAGE_offset = 1
Due to using absolute values the true range and the Average true range are always positive. It measures only volatility, not direction. You should use other strategies to supplement the ATR strategy.