OPEN-SOURCE SCRIPT
Turtle Trading System Indicator

Key Features & Components
Donchian Channels
The core of the indicator is the Donchian Channel, represented by the upper and lower blue bands.
Upper Channel: The highest price over a user-defined period.
Lower Channel: The lowest price over the same period.
Middle Line: The midpoint between the upper and lower channels.
These channels are used to identify potential breakouts, which form the basis for trade entries.
Trading Signals
The script automatically generates clear, non-repainting signals for potential trades:
Long Entry (Green ▲): A green upward-facing triangle appears below the candle when the closing price breaks above the upper Donchian channel, signaling the start of a potential uptrend.
Short Entry (Red ▼): A red downward-facing triangle appears above the candle when the closing price breaks below the lower Donchian channel, signaling the start of a potential downtrend.
Long Exit (Green X): A green cross appears above the candle when the price crosses below the middle line, suggesting the uptrend is weakening.
Short Exit (Orange X): An orange cross appears below the candle when the price crosses above the middle line, suggesting the downtrend is losing momentum.
Integrated Risk Management
A crucial element of the Turtle strategy is disciplined risk management, which is built into this indicator.
Volatility-Based Position Sizing
You can enable position sizing that adapts to market volatility using the Average True Range (ATR). When an entry signal occurs, a label appears showing a calculated position size unit. The formula aims to normalize risk, meaning you would trade smaller sizes in volatile markets and larger sizes in calmer markets. The formula used is:
Volatility Unit=
100
Risk %
×
4×ATR
Close Price
Dynamic Stop Loss
Upon a long or short entry, a stop-loss level is plotted on the chart as red circles. This level is calculated based on the ATR, automatically adjusting to the market's current volatility to provide a data-driven exit point for managing losses. It is calculated as:
Long Stop: Close Price - 1.8 * ATR
Short Stop: Close Price + 1.8 * ATR
On-Chart Information Panel
A convenient table is displayed in the bottom-right corner of the chart, showing the current ATR value and the calculated Position Size unit for quick and easy reference.
Customizable Settings
You can tailor the indicator to your specific strategy and risk tolerance:
Donchian Channel Period: Sets the lookback period for the channels. The default is 20. Shorter periods will be more sensitive and generate more signals.
ATR Period: Sets the lookback period for the Average True Range calculation, affecting both position size and stop-loss levels. The default is 14.
Risk Percentage: The percentage of equity you wish to risk per trade. This directly influences the position size calculation.
Use Volatility Position Sizing: A simple checkbox to turn the ATR-based position sizing on or off.
Donchian Channels
The core of the indicator is the Donchian Channel, represented by the upper and lower blue bands.
Upper Channel: The highest price over a user-defined period.
Lower Channel: The lowest price over the same period.
Middle Line: The midpoint between the upper and lower channels.
These channels are used to identify potential breakouts, which form the basis for trade entries.
Trading Signals
The script automatically generates clear, non-repainting signals for potential trades:
Long Entry (Green ▲): A green upward-facing triangle appears below the candle when the closing price breaks above the upper Donchian channel, signaling the start of a potential uptrend.
Short Entry (Red ▼): A red downward-facing triangle appears above the candle when the closing price breaks below the lower Donchian channel, signaling the start of a potential downtrend.
Long Exit (Green X): A green cross appears above the candle when the price crosses below the middle line, suggesting the uptrend is weakening.
Short Exit (Orange X): An orange cross appears below the candle when the price crosses above the middle line, suggesting the downtrend is losing momentum.
Integrated Risk Management
A crucial element of the Turtle strategy is disciplined risk management, which is built into this indicator.
Volatility-Based Position Sizing
You can enable position sizing that adapts to market volatility using the Average True Range (ATR). When an entry signal occurs, a label appears showing a calculated position size unit. The formula aims to normalize risk, meaning you would trade smaller sizes in volatile markets and larger sizes in calmer markets. The formula used is:
Volatility Unit=
100
Risk %
×
4×ATR
Close Price
Dynamic Stop Loss
Upon a long or short entry, a stop-loss level is plotted on the chart as red circles. This level is calculated based on the ATR, automatically adjusting to the market's current volatility to provide a data-driven exit point for managing losses. It is calculated as:
Long Stop: Close Price - 1.8 * ATR
Short Stop: Close Price + 1.8 * ATR
On-Chart Information Panel
A convenient table is displayed in the bottom-right corner of the chart, showing the current ATR value and the calculated Position Size unit for quick and easy reference.
Customizable Settings
You can tailor the indicator to your specific strategy and risk tolerance:
Donchian Channel Period: Sets the lookback period for the channels. The default is 20. Shorter periods will be more sensitive and generate more signals.
ATR Period: Sets the lookback period for the Average True Range calculation, affecting both position size and stop-loss levels. The default is 14.
Risk Percentage: The percentage of equity you wish to risk per trade. This directly influences the position size calculation.
Use Volatility Position Sizing: A simple checkbox to turn the ATR-based position sizing on or off.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。