OPEN-SOURCE SCRIPT

Estrategia Trend Following: 52w/26w Breakout

55
This is a classic long-term Trend Following strategy, heavily inspired by the Donchian Channel system and the legendary "Turtle Trading" rules. It is designed to capture major market moves (bull runs) while filtering out short-term market noise and volatility.

This script is ideal for investors and swing traders who prefer a "hands-off" approach, looking to catch large trends rather than day-trading small fluctuations.

How it Works:
1. Entry Condition (The Breakout):

52-Week High: The strategy enters a Long position when the price breaks above the highest high of the last 252 trading days (approx. 1 year).

SuperTrend Filter: An additional filter using the SuperTrend indicator ensures that the breakout is supported by positive momentum, helping to reduce false signals during choppy lateral markets.

2. Exit Condition (The Trailing Stop):

26-Week Low: The strategy ignores short-term corrections. It only closes the position if the price closes below the lowest low of the last 126 trading days (approx. 6 months).

This wide stop allows the trade to "breathe" and stay open during significant pullbacks, ensuring you stay in the trend for as long as possible.

Features & Settings:
Customizable Lookback Periods: You can adjust the Entry (default 252 days) and Exit (default 126 days) periods in the settings menu.

Visual Aids:

Blue Line: Represents the 1-Year High (Entry Threshold).

Red Line: Represents the 6-Month Low (Dynamic Stop Loss).

Channel Shading: Visualizes the trading range between the high and low.

Labels: Clearly marks "BUY" and "EXIT" points on the chart.

Recommended Usage:
Timeframe: Daily (1D). This logic is designed for daily candles.

Assets: Works best on assets with strong trending characteristics (e.g., Bitcoin/Crypto, Tech Stocks, Indices like SPX/NDX, and Commodities).

Patience Required: This strategy generates very few signals. It may stay quiet for months and then hold a position for over a year.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.