ATR Based Trend Tracking Strategy
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
- Based on trend judgment, it can follow the trend continuously for profit
- Use ATR to dynamically adjust stop loss distance, effectively control risks
- Simple and direct to calculate entry and exit points, easy to understand and implement
Risks & Solutions
- May encounter large losses when trend changes
- Adjust ATR period and multiplier reasonably to optimize stop loss distance
- WILL generate multiple small losses in ranging markets
- Add filter conditions to avoid ranging markets
- Improper parameter settings may worsen strategy performance
- Conduct multi-parameter optimization to find optimum
Optimization Directions
- Add other indicators for filtering to avoid opening positions in ranging markets
- Optimize ATR period and multiplier parameters to make stop distance more reasonable
- 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.
/*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')- 1

