OPEN-SOURCE SCRIPT

Auto Trend [theUltimator5]

510
The Auto Trend indicator was designed to be a unique pattern detection indicator without the use of standard pivot point logic or high/low lines. It is a study in pattern detection by using iterative best-fit logic.

The indicator automatically identifies and draws trend channels by analyzing price action across configurable lookback periods. It finds optimal high and low trendlines that contain price movement, with a middle line marking the trend's center.


Key Features:
  • Automatic Pattern Detection - Intelligently searches for the best lookback period where price stays within the channel boundaries
  • Dual Pattern Modes - Choose between Short (20-66 bars) for quick patterns or Long (50-500 bars) for extended trends. Note - the long pattern is fully configurable and can be set anywhere up to 5000 bars.
  • Smart Caching - Optimized performance that only recalculates when necessary
  • Customizable Starting Point - Click directly on the chart to set where the trend channel begins
  • Flexible Lookback Range - Set minimum and maximum lookback periods to match your trading style
  • Visual Debugging - Optional label displays the active lookback period and violation count



How It Works:

The indicator divides the lookback period into thirds, finds the highest and lowest closes in the first and last thirds, then draws trendlines connecting these points. It can automatically search through different lookback periods to find the one with the fewest price violations (closes outside the channel).


Settings:
  • Use Auto Lookback - Enable automatic optimal lookback detection
  • Pattern Length - Short (faster, 1-bar increments) or Long (broader, 5-bar increments)
  • Min/Max Lookback - Define the search range for the Long pattern
  • Manual Lookback - Override auto-detection with a fixed period
  • Custom Colors - Personalize the high, low, and middle line colors
  • Starting Point - Select where the trend analysis begins



Use Cases:
  • Identify dominant trend channels across different timeframes
  • Spot potential support and resistance levels
  • Determine trend strength and consistency
  • Time entries and exits based on channel position


The indicator supports up to 5000 bars of historical data for comprehensive trend analysis.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.