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
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.