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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.