OPEN-SOURCE SCRIPT
Trend Following $BTC - Multi-Timeframe Structure + Revers

TREND FOLLOWING STRATEGY - MULTI-TIMEFRAME STRUCTURE BREAKOUT SYSTEM
Strategy Overview
This is an enhanced Turtle Trading system designed for cryptocurrency spot trading. It combines Donchian Channel breakouts with multi-timeframe structure filtering and ATR-based dynamic risk management. The strategy trades both long and short positions using reverse signal exits to maximize trend capture.
Core Features
Multi-Timeframe Structure Filtering
The strategy uses Swing High/Low analysis to identify market structure trends. You can customize the structure timeframe (default: 3 minutes) to match your trading style. Only enters trades aligned with the identified trend direction, avoiding counter-trend positions that often lead to losses.
Reverse Signal Exit System
Instead of using fixed stop-losses or time-based exits, this strategy exits positions only when a reverse entry signal triggers. This approach maximizes trend profits and reduces premature exits during normal market retracements.
ATR Dynamic Pyramiding
Automatically adds positions when price moves 0.5 ATR in your favor. Supports up to 2 units maximum (adjustable). This pyramid scaling enhances profitability during strong trends while maintaining disciplined risk management.
Complete Risk Management
Fixed position sizing at 5000 USD per unit. Includes realistic commission fees of 0.06% (Binance spot rate). Initial capital set at 10,000 USD. All backtest parameters reflect real-world trading conditions.
Trading Logic
Entry Conditions
Long Entry: Close price breaks above the 20-period high AND structure trend is bullish (price breaks above Swing High)
Short Entry: Close price breaks below the 20-period low AND structure trend is bearish (price breaks below Swing Low)
Position Scaling
Long positions: Add when price rises 0.5 ATR or more
Short positions: Add when price falls 0.5 ATR or more
Maximum 2 units including initial entry
Exit Conditions
Long Exit: Triggers when short entry signal appears (price breaks 20-period low + structure turns bearish)
Short Exit: Triggers when long entry signal appears (price breaks 20-period high + structure turns bullish)
Default Parameters
Channel Settings
Entry Channel Period: 20 (Donchian Channel breakout period)
Exit Channel Period: 10 (reserved parameter)
ATR Settings
ATR Period: 20
Stop Loss ATR Multiplier: 2.0
Add Position ATR Multiplier: 0.5
Structure Filter
Swing Length: 300 (Swing High/Low calculation period)
Structure Timeframe: 3 minutes
Adjust these based on your trading timeframe and asset volatility
Position Management
Maximum Units: 2 (including initial entry)
Capital Per Unit: 5000 USD
Visualization Features
Background Colors
Light Green: Bullish market structure
Light Red: Bearish market structure
Dark Green: Long position entry
Dark Red: Short position entry
Optional Display Elements (Default: OFF)
Entry and exit channel lines
Structure high/low reference lines
ATR stop-loss indicator
Next position add level
Entry/exit labels
Alert Message Format
The strategy sends notifications with the following format:
Entry: "5m Long EP:90450.50"
Add Position: "15m Add Long 2/2 EP:91000.25"
Exit: "5m Close Long Reverse Signal"
Where the first part shows your current chart timeframe and EP indicates Entry Price
Backtest Settings
Capital Allocation
Initial Capital: 10,000 USD
Per Entry: 5,000 USD (split into 2 potential entries)
Leverage: 0x (spot trading only)
Trading Costs
Commission: 0.06% (Binance spot VIP0 rate)
Slippage: 0 (adjust based on your experience)
Best Use Cases
Ideal Scenarios
Trending markets with clear directional movement
Moderate to high volatility assets
Timeframes from 1-minute to 4-hour charts
Best suited for major cryptocurrencies with good liquidity
Not Recommended For
Highly volatile choppy/ranging markets
Low liquidity small-cap coins
Extreme market conditions or black swan events
Usage Recommendations
Timeframe Guidelines
1-5 minute charts: Use for scalping, consider Swing Length 100-160
15-30 minute charts: Good for short-term trading, Swing Length 50-100
1-4 hour charts: Suitable for swing trading, Swing Length 20-50
Optimization Tips
Always backtest on historical data before live trading
Adjust swing length based on asset volatility and your timeframe
Different cryptocurrencies may require different parameter settings
Enable visualization options initially to understand entry/exit points
Monitor win rate and drawdown during backtesting
Technical Details
Built on Pine Script v6
No repainting - uses proper bar referencing with [1] offset
Prevents lookahead bias with lookahead=off parameter
Strategy mode with accurate commission and slippage modeling
Multi-timeframe security function for structure analysis
Proper position state tracking to avoid duplicate signals
Risk Disclaimer
This strategy is provided for educational and research purposes only. Past performance does not guarantee future results. Backtesting results may differ from live trading due to slippage, execution delays, and changing market conditions. The strategy performs best in trending markets and may experience drawdowns during ranging conditions. Always practice proper risk management and never risk more than you can afford to lose. It is recommended to paper trade first and start with small position sizes when going live.
How to Use
Add the strategy to your TradingView chart
Select your desired timeframe (1m to 4h recommended)
Adjust parameters based on your risk tolerance and trading style
Review backtest results in the Strategy Tester tab
Set up alerts for automated notifications
Consider paper trading before risking real capital
Tags
Trend Following, Turtle Trading, Donchian Channel, Structure Breakout, ATR, Cryptocurrency, Spot Trading, Risk Management, Pyramiding, Multi-Timeframe Analysis
---
Strategy Name: Trend Following BTC
Version: v1.0
Pine Script Version: v6
Last Updated: December 2025
Strategy Overview
This is an enhanced Turtle Trading system designed for cryptocurrency spot trading. It combines Donchian Channel breakouts with multi-timeframe structure filtering and ATR-based dynamic risk management. The strategy trades both long and short positions using reverse signal exits to maximize trend capture.
Core Features
Multi-Timeframe Structure Filtering
The strategy uses Swing High/Low analysis to identify market structure trends. You can customize the structure timeframe (default: 3 minutes) to match your trading style. Only enters trades aligned with the identified trend direction, avoiding counter-trend positions that often lead to losses.
Reverse Signal Exit System
Instead of using fixed stop-losses or time-based exits, this strategy exits positions only when a reverse entry signal triggers. This approach maximizes trend profits and reduces premature exits during normal market retracements.
ATR Dynamic Pyramiding
Automatically adds positions when price moves 0.5 ATR in your favor. Supports up to 2 units maximum (adjustable). This pyramid scaling enhances profitability during strong trends while maintaining disciplined risk management.
Complete Risk Management
Fixed position sizing at 5000 USD per unit. Includes realistic commission fees of 0.06% (Binance spot rate). Initial capital set at 10,000 USD. All backtest parameters reflect real-world trading conditions.
Trading Logic
Entry Conditions
Long Entry: Close price breaks above the 20-period high AND structure trend is bullish (price breaks above Swing High)
Short Entry: Close price breaks below the 20-period low AND structure trend is bearish (price breaks below Swing Low)
Position Scaling
Long positions: Add when price rises 0.5 ATR or more
Short positions: Add when price falls 0.5 ATR or more
Maximum 2 units including initial entry
Exit Conditions
Long Exit: Triggers when short entry signal appears (price breaks 20-period low + structure turns bearish)
Short Exit: Triggers when long entry signal appears (price breaks 20-period high + structure turns bullish)
Default Parameters
Channel Settings
Entry Channel Period: 20 (Donchian Channel breakout period)
Exit Channel Period: 10 (reserved parameter)
ATR Settings
ATR Period: 20
Stop Loss ATR Multiplier: 2.0
Add Position ATR Multiplier: 0.5
Structure Filter
Swing Length: 300 (Swing High/Low calculation period)
Structure Timeframe: 3 minutes
Adjust these based on your trading timeframe and asset volatility
Position Management
Maximum Units: 2 (including initial entry)
Capital Per Unit: 5000 USD
Visualization Features
Background Colors
Light Green: Bullish market structure
Light Red: Bearish market structure
Dark Green: Long position entry
Dark Red: Short position entry
Optional Display Elements (Default: OFF)
Entry and exit channel lines
Structure high/low reference lines
ATR stop-loss indicator
Next position add level
Entry/exit labels
Alert Message Format
The strategy sends notifications with the following format:
Entry: "5m Long EP:90450.50"
Add Position: "15m Add Long 2/2 EP:91000.25"
Exit: "5m Close Long Reverse Signal"
Where the first part shows your current chart timeframe and EP indicates Entry Price
Backtest Settings
Capital Allocation
Initial Capital: 10,000 USD
Per Entry: 5,000 USD (split into 2 potential entries)
Leverage: 0x (spot trading only)
Trading Costs
Commission: 0.06% (Binance spot VIP0 rate)
Slippage: 0 (adjust based on your experience)
Best Use Cases
Ideal Scenarios
Trending markets with clear directional movement
Moderate to high volatility assets
Timeframes from 1-minute to 4-hour charts
Best suited for major cryptocurrencies with good liquidity
Not Recommended For
Highly volatile choppy/ranging markets
Low liquidity small-cap coins
Extreme market conditions or black swan events
Usage Recommendations
Timeframe Guidelines
1-5 minute charts: Use for scalping, consider Swing Length 100-160
15-30 minute charts: Good for short-term trading, Swing Length 50-100
1-4 hour charts: Suitable for swing trading, Swing Length 20-50
Optimization Tips
Always backtest on historical data before live trading
Adjust swing length based on asset volatility and your timeframe
Different cryptocurrencies may require different parameter settings
Enable visualization options initially to understand entry/exit points
Monitor win rate and drawdown during backtesting
Technical Details
Built on Pine Script v6
No repainting - uses proper bar referencing with [1] offset
Prevents lookahead bias with lookahead=off parameter
Strategy mode with accurate commission and slippage modeling
Multi-timeframe security function for structure analysis
Proper position state tracking to avoid duplicate signals
Risk Disclaimer
This strategy is provided for educational and research purposes only. Past performance does not guarantee future results. Backtesting results may differ from live trading due to slippage, execution delays, and changing market conditions. The strategy performs best in trending markets and may experience drawdowns during ranging conditions. Always practice proper risk management and never risk more than you can afford to lose. It is recommended to paper trade first and start with small position sizes when going live.
How to Use
Add the strategy to your TradingView chart
Select your desired timeframe (1m to 4h recommended)
Adjust parameters based on your risk tolerance and trading style
Review backtest results in the Strategy Tester tab
Set up alerts for automated notifications
Consider paper trading before risking real capital
Tags
Trend Following, Turtle Trading, Donchian Channel, Structure Breakout, ATR, Cryptocurrency, Spot Trading, Risk Management, Pyramiding, Multi-Timeframe Analysis
---
Strategy Name: Trend Following BTC
Version: v1.0
Pine Script Version: v6
Last Updated: December 2025
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.