OPEN-SOURCE SCRIPT
Turtle System 2 (55/20) + N-Stop + MTF Table V7.2

🐢 Description: Turtle System 2 (55/20) IndicatorThis indicator implements the trading signals of the Turtle Trading System 2 based on the classic Donchian Channels, supplemented by a historically correct, volatility-based Trailing Stop (N-Stop) and a Multi-Timeframe (MTF) status overview. The script was developed in Pine Script v6 and is optimized for performance and robustness.📊 Core Logic and ParametersThe indicator is based on the rule-based trend-following system developed by Richard Dennis and William Eckhardt, utilizing the more aggressive Entry/Exit parameters of System 2:FunctionParameterValueDescriptionEntry$\text{Donchian Breakout}$$\mathbf{55}$Buy/Sell upon breaking the 55-day High/Low.Exit (Turtle)$\text{Donchian Breakout}$$\mathbf{20}$Close the position upon breaking the 20-day Low/High.Volatility$\mathbf{N}$ (ATR Period)$\mathbf{20}$Calculation of market volatility using the Average True Range (ATR).Stop-LossMultiplier$\mathbf{2.0}
SETS the initial and Trailing Stop at $\mathbf{2N}$.🛠️ Technical Implementation1. Correct Trailing Stop (Section 4)In contrast to many flawed implementations, the Trailing Stop is implemented here according to the Original Turtle Logic. The stop price (current_stop_price) is not aggressively tied to the current low or high. Instead, at the close of each bar, it is only trailed in the direction of the trade (math.max for long positions) based on the formula:$$\text{New Trailing Stop} = \text{max}(\text{Previous Stop}, \text{Close} \pm (2 \times N))$$This ensures the stop is only adjusted upon sustained positive movement and is not prematurely triggered by short-term, deep price shadows.2. Reliable Multi-Timeframe (MTF) Logic (Section 6)The MTF section utilizes global var int variables (mtf_status_1h, mtf_status_D, etc.) in conjunction with the request.security() function.Purpose: Calculates and persistently stores the current Turtle System 2 status (LONG=1, SHORT=-1, FLAT=0) for the timeframes 1H, 4H, 8H, 1D, and 1W.Advantage: By persistently storing the status using the var variables, the critical error of single-update status is eliminated. The states shown in the table are reliable and accurately reflect the Turtle System's position status on the respective timeframes.3. Visual ComponentsDonchian Channels: The entry (55-period) and exit (20-period) channels are drawn with color highlighting.N-Stop Line: The dynamically calculated Trailing Stop ($\mathbf{2N}$) is displayed as a magenta line.Visual Signals: plotshape markers indicate Entry and Exit points.MTF Table: A compact status summary with color coding (Green/Red/Gray) for the higher timeframes is displayed in the upper right corner.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.