OPEN-SOURCE SCRIPT

Donchian and Keltner Channels Trend Following with Trailing Stop

203
Long Only Trend-following model based on Keltner Channels and Donchian Channels.
These indicators include a noise region, which allows prices to oscillate without requiring position adjustments.
When price trades above the upper band, it signals strength; when it trades below the lower band, it signals weakness.

Keltner Channels
Keltner Channels are volatility-based envelopes set above and below an exponential moving average. Keltner Channels use the Average True Range (ATR), which measures daily volatility, to set channel distance.

Donchian Channel
Donchian Channels are are used to identify market trends and volatility. The upper and lower bands are based on the highest high and lowest low of a specified period. When the price moves above the upper band, it indicates a bullish breakout, while a
move below the lower band indicates a bearish breakout. The distance between the upper and lower channel of the Donchian Channel indicates the asset’s volatility.

Trend Following Model
The default settings are:

Upper Keltner and Upper Donchian Channel Length : 20
Lower Keltner and Lower Donchian Channel Length : 40
Keltner ATR Multiplier: 2

Entries, Exits and Trailing Stop
  1. Entry: When price exceeds the upper band of at least one of these indicators.
  2. Exit: When price undercuts the lower band of at least one of these indicators.
  3. Trailing Stop: See below.


Trailing Stop
This is a stop-loss order that moves with the price of the underlying. It is designed to “trail” the price up (in the case of a long position) or down (for a short position), locking in profits as the price moves in a favorable direction.

At the end of day t, there was a Trailing Stop level in place. For the next day (day t + 1), the Trailing Stop will be adjusted. The new Trailing Stop will be the higher of two values:
  • The Trailing Stop from the previous day (day t).
  • The Lower Band computed at the end of day t + 1.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.