OPEN-SOURCE SCRIPT
ที่อัปเดต: 0 Turtle Breakout Pro v6.13

0 Turtle Breakout Pro v6.12
Overview
The Turtle Breakout Pro is a modern, highly advanced homage to the legendary Turtle Trading system engineered by Richard Dennis and William Eckhardt. This script transforms a traditional Donchian Channel breakout indicator into a fully-fledged, institutional-grade risk management engine. It doesn't just trade price action; it trades volatility.
Designed for Pine Script v6, this strategy dynamically adapts to market conditions by calculating position sizes based on the Average True Range (ATR – the famous Turtle "N"). It includes a comprehensive backtesting dashboard that introduces advanced metrics, such as distinguishing between "Time in Market" and actual "Capital Deployed".
Core Mechanics & Strategy Logic
The Entry (Donchian Breakout): The system triggers entries based on price breakouts from the Donchian Channel. You can customize the channel lengths for the upper and lower bands independently.
Dynamic Position Sizing (The "N"): This is the heart of the Turtle philosophy. By enabling position sizing, the strategy calculates the exact quantity to buy/sell so that a hit to your ATR Stop Loss will only cost you a predefined percentage of your total equity (e.g., 2%).
The 2N Stop-Loss: The system features an optional, hard ATR-based stop loss. It calculates the ATR at the exact moment of entry and freezes the stop-loss level, protecting your capital from sudden market crashes.
Volatility Filter: An optional ATR SMA filter ensures the system only takes breakout setups when the market is actively expanding, filtering out choppy, low-momentum sideways markets.
Key Features & Upgrades
Pro Dashboard (Table): A sleek, non-intrusive UI panel displaying deep performance metrics:
Comparison against Buy & Hold
CAGR, Max Drawdown, and absolute Return
Sharpe Ratio and Calmar Ratio
Advanced Exposure Tracking: Clearly separates "Time in Market" (how often you are in a trade) from "Avg. Capital Deployed" (how much of your cash is actually at risk).
Live Exposure Labels: Plots a dynamic label directly on the chart for every executed trade, showing you exactly what percentage of your total equity is deployed in that specific position. The distance of the label is dynamically tied to the ATR to prevent overlapping with chart candles.
Crash-Proof Math Engine: The sizing formula is fortified against runtime errors (RE 10024). It seamlessly handles micro-fractions for Crypto and Forex markets while ignoring infinite values caused by broken broker data.
Time Filtering: Built-in date range inputs allow for precise historical backtesting without altering the code.
How to Use
Apply to your chart and open the settings (⚙️).
Set your Max Position Risk % (Standard Turtle rule is 1% to 2%).
Adjust the ATR Risk Offset and ATR Stop Multiplier (Standard is 2.0 to replicate the classic 2N-Stop).
Decide if you want to allow Short Trades or run the system as a Long-Only trend follower.
Disclaimer: Trend following systems typically experience a lower win rate but capture massive outliers. Ensure you understand the psychological requirements of sitting through drawdowns before trading this system live.
Overview
The Turtle Breakout Pro is a modern, highly advanced homage to the legendary Turtle Trading system engineered by Richard Dennis and William Eckhardt. This script transforms a traditional Donchian Channel breakout indicator into a fully-fledged, institutional-grade risk management engine. It doesn't just trade price action; it trades volatility.
Designed for Pine Script v6, this strategy dynamically adapts to market conditions by calculating position sizes based on the Average True Range (ATR – the famous Turtle "N"). It includes a comprehensive backtesting dashboard that introduces advanced metrics, such as distinguishing between "Time in Market" and actual "Capital Deployed".
Core Mechanics & Strategy Logic
The Entry (Donchian Breakout): The system triggers entries based on price breakouts from the Donchian Channel. You can customize the channel lengths for the upper and lower bands independently.
Dynamic Position Sizing (The "N"): This is the heart of the Turtle philosophy. By enabling position sizing, the strategy calculates the exact quantity to buy/sell so that a hit to your ATR Stop Loss will only cost you a predefined percentage of your total equity (e.g., 2%).
The 2N Stop-Loss: The system features an optional, hard ATR-based stop loss. It calculates the ATR at the exact moment of entry and freezes the stop-loss level, protecting your capital from sudden market crashes.
Volatility Filter: An optional ATR SMA filter ensures the system only takes breakout setups when the market is actively expanding, filtering out choppy, low-momentum sideways markets.
Key Features & Upgrades
Pro Dashboard (Table): A sleek, non-intrusive UI panel displaying deep performance metrics:
Comparison against Buy & Hold
CAGR, Max Drawdown, and absolute Return
Sharpe Ratio and Calmar Ratio
Advanced Exposure Tracking: Clearly separates "Time in Market" (how often you are in a trade) from "Avg. Capital Deployed" (how much of your cash is actually at risk).
Live Exposure Labels: Plots a dynamic label directly on the chart for every executed trade, showing you exactly what percentage of your total equity is deployed in that specific position. The distance of the label is dynamically tied to the ATR to prevent overlapping with chart candles.
Crash-Proof Math Engine: The sizing formula is fortified against runtime errors (RE 10024). It seamlessly handles micro-fractions for Crypto and Forex markets while ignoring infinite values caused by broken broker data.
Time Filtering: Built-in date range inputs allow for precise historical backtesting without altering the code.
How to Use
Apply to your chart and open the settings (⚙️).
Set your Max Position Risk % (Standard Turtle rule is 1% to 2%).
Adjust the ATR Risk Offset and ATR Stop Multiplier (Standard is 2.0 to replicate the classic 2N-Stop).
Decide if you want to allow Short Trades or run the system as a Long-Only trend follower.
Disclaimer: Trend following systems typically experience a lower win rate but capture massive outliers. Ensure you understand the psychological requirements of sitting through drawdowns before trading this system live.
Release Note
// v6.14: Fixed Max Position Exposure calculation and added visual plots for ATR Stop Loss (lines) & ATR Volatility Filter (background).
Release Note
v6.16: Added Profit Factor, Win Rate, and Average Win/Loss Ratio to the performance dashboard.Release Note
v6.17: ATR Stop lines automatically disappear when trailing Donchian bands overtake them.Release Note
v6.18: Added optional Pyramiding (Scale-In) logic with remaining capital. Updated default ATR & Risk parameters.Release Note
// v6.22: Refactored Position Sizing to calculate exact Exposure based on anticipated execution (Stop) price.// v6.23: Updated default parameters (ATR 2, Risk 2.25). Added dynamic Dashboard Positioning and Sortino Ratio.
Release Note
// v6.25: Fixed Buy & Hold metrics to freeze when the Backtest End Date is reached instead of using current chart prices.// v6.26: Fixed parsing error (line too long) by replacing nested ternary operators with a switch statement for dashboard position.
Release Note
v6.27: Added Custom Interest Rate (Borrowing Costs) logic to adjust equity and metrics for realistic leverage simulation.// v6.28: Fixed local scope history reference warning for 'adj_equity[1]' inside the performance metrics calculation.
Release Note
// v6.29: Added Adj. Sortino and Calmar (by Capital Exposure). Reordered Dashboard.// v6.30: Removed maxval=100 limit on Exposure for leverage support. Fixed accurate Label Calculation by reversing openprofit.
// v6.31: Integrated 3 Drawdown Calculations (Strict Float, TV Standard, Closed) with Intra-Bar accuracy into the dashboard.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน