Type/to search

ATR Based Trend Tracking Strategy

Common strategy
Created: 2024-01-05 16:28:48
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

This is a trend tracking strategy based on Average True Range (ATR). It uses ATR to calculate indicator values and determine price trend direction. The strategy also provides a stop loss mechanism to control risks.

Strategy Logic

The strategy uses three main parameters: Period, Multiplier and Entry/Exit Point. The default parameters are 14 periods of ATR and a multiplier of 4.

The strategy first calculates the long average price (buyavg) and short average price (sellavg), then compares the price relationship between these two averages to determine the current trend direction. If the price is higher than the short average price, it is judged as long; if the price is lower than the long average price, it is judged as short.

In addition, the strategy incorporates ATR to set a trailing stop loss. Specifically, it uses the 14-period weighted moving average of ATR multiplied by a multiplier (default 4) as the stop loss distance. This allows the stop loss distance to be adjusted based on market volatility.

When the stop loss is triggered, the strategy will close the position to lock in profits.

Advantages

  1. Based on trend judgment, it can follow the trend continuously for profit
  2. Use ATR to dynamically adjust stop loss distance, effectively control risks
  3. Simple and direct to calculate entry and exit points, easy to understand and implement

Risks & Solutions

  1. May encounter large losses when trend changes
    • Adjust ATR period and multiplier reasonably to optimize stop loss distance
  2. WILL generate multiple small losses in ranging markets
    • Add filter conditions to avoid ranging markets
  3. Improper parameter settings may worsen strategy performance
    • Conduct multi-parameter optimization to find optimum

Optimization Directions

  1. Add other indicators for filtering to avoid opening positions in ranging markets
  2. Optimize ATR period and multiplier parameters to make stop distance more reasonable
  3. Add position sizing control based on market conditions

Conclusion

Overall this is a simple and practical trend tracking strategy. It only needs a few parameters to implement, and uses ATR to dynamically adjust stops to effectively control risks. When combined with other assisting indicators for filtering, it can be further optimized. In general, this strategy suits those who want to learn about trend tracking strategies, and can also be used as a basic component for more advanced strategies.

Source
Pine
/*backtest
start: 2022-12-29 00:00:00
end: 2024-01-04 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Trend Strategy by zdmre', shorttitle='Trend Strategy', overlay=true, pyramiding=0, currency=currency.USD, default_qty_type=strategy.percent_of_equity, initial_capital=10000, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.005)
show_STOPLOSSprice = input(true, title='Show TrailingSTOP Prices')
src = input(close, title='Source')
Strategy parameters
Strategy parameters
Show TrailingSTOP Prices
Source
From Month
From Day
From Year
Thru Month
Thru Day
Thru Year
Show Date Range
ATR_Period
ATR_Mult
ShortPosition
Stop Loss
╔══════   Enable   ══════╗
Based on
ATR   Mult
Length
Percent
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)