Type/to search

CCI and ATR Based Trend Following Strategy

Cryptocurrency
Created: 2023-09-26 16:08:37
Last modified: 3 years ago
1
Follow
1781
Followers

Overview

This strategy identifies price trends by combining Average True Range (ATR) and Commodity Channel Index (CCI), and uses overbought/oversold levels as entry and exit signals. ATR calculates the upper and lower bands, while CCI determines the trend direction. It goes short when CCI crosses below overbought level, and goes long when CCI crosses above oversold level, thus following trends.

Strategy Logic

  1. Calculate ATR, here 2-period ATR is used
  2. Calculate CCI value, here 10-period CCI is used
  3. Determine trend direction based on current CCI value
    • CCI >= 0, Defines as Uptrend
    • CCI < 0, Defines as Downtrend
  4. Calculate Upper Band and Lower Band
    • Upper Band = Highest High + ATR * Multiplier
    • Lower Band = Lowest Low - ATR * Multiplier
  5. Under different trend directions, save and update Upper and Lower Bands
    • When CCI >= 0, if Upper Band < previous Upper Band, reset it; When CCI < 0, if Lower Band > previous Lower Band, reset it
    • This avoids channels moving reversely with price
  6. Enter at Upper or Lower band based on CCI value as entry signal
  7. Exit when CCI crosses 0 as exit signal
  8. Set stop loss and take profit exit

Advantages

This strategy combines trend identification and channel breakout, which effectively follows trends.

  1. Using CCI to determine price trend direction for quick judgment of long/short trends
  2. ATR channel sets stop loss and take profit to control risks
  3. Channels can quickly adjust direction when price reverses, avoiding being trapped in original trend channel
  4. Exiting on CCI's 0 cross follows trends and avoids whipsaws

Risks and Improvements

  1. CCI and ATR parameters need optimization for best results across periods and parameters
  2. Although channel adjustment avoids congestion, severe reversals may still cause insufficient profit or loss
  3. Stop loss placement needs optimization, relax stops to avoid excessive stops
  4. Additional filters on entry signal can optimize entry opportunities
  5. Combining with higher timeframe trend indicator can avoid trading against higher trend

Summary

Overall this is a simple and practical trend following strategy. Its advantage is clear logic and ease of implementation for quickly capitalizing on trends. But parameters like stop loss range require optimization based on market conditions. Combining with other indicators can further enhance the strategy. As a beginner trend following strategy, it is worth learning and referencing.

Source
Pine
/*backtest
start: 2023-08-26 00:00:00
end: 2023-09-25 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Trend Trader Karan",overlay=true)
res = input(title="Resolution", type=input.resolution, defval="60",confirm = true)
Strategy parameters
Strategy parameters
Resolution
Take Profit (%)
Stop Loss (%)
CCI
ATR
src
len0
Range
loockback length pivots
Draw lines from wicks (checked) or real bodies (unchecked)?
Display only falling 'high' and rising 'low' trendlines?
checked = monochrome lines, unchecked = direction colored lines?
Limit extensions of the lines? 0 = infinite, other values x 100 bars
show trendline breaks
number of past trendlines to check for breaks (max = 10)
only display 'long' breaks on trendlines connecting 'highs' and 'short' for 'lows'
USING A LOG CHART? MAKE SURE TO CHECK THIS BOX!!
Period
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)