OPEN-SOURCE SCRIPT
Güncellendi

Advanced Swing High/Low Trend Lines with MA Filter

2 040
# Advanced Swing High/Low Trend Lines Indicator

## Overview
This advanced indicator identifies and draws trend lines based on swing highs and lows across three different timeframes (large, middle, and small trends). It's designed to help traders visualize market structure and potential support/resistance levels at multiple scales simultaneously.

## Key Features

- *Multi-Timeframe Analysis*: Simultaneously tracks trends at large (200-bar), middle (100-bar), and small (50-bar) scales
- *Customizable Visualization*: Different colors, widths, and styles for each trend level
- *Trend Confirmation System*: Requires minimum consecutive pivot points to validate trends
- *Trend Filter Option*: Can align trends with 200 EMA direction for consistency

## Recommended Settings

### For Long-Term Investors:
- Large Swing Length: 200-300
- Middle Swing Length: 100-150
- Small Swing Length: 50-75
- Enable Trend Filter: Yes
- Confirmation Points: 4-5

### For Swing Traders:
- Large Swing Length: 100
- Middle Swing Length: 50
- Small Swing Length: 20-30
- Enable Trend Filter: Optional
- Confirmation Points: 3

### For Day Traders:
- Large Swing Length: 50
- Middle Swing Length: 20
- Small Swing Length: 5-10
- Enable Trend Filter: No
- Confirmation Points: 2-3

## How to Use

### Identification:
1. *Large Trend Lines* (Red/Green): Show major market structure
2. *Middle Trend Lines* (Purple/Aqua): Intermediate levels
3. *Small Trend Lines* (Orange/Blue): Short-term price action

### Trading Applications:
- *Breakout Trading*: Watch for price breaking through multiple trend lines
- *Bounce Trading*: Look for reactions at confluence of trend lines
- *Trend Confirmation*: Aligned trends across timeframes suggest stronger moves

### Best Markets:
- Works well in trending markets (forex, indices)
- Effective in higher timeframes (1H+)
- Can be used in ranging markets to identify boundaries

## Customization Tips

1. For cleaner charts, reduce line widths in congested markets
2. Use dotted styles for smaller trends to reduce visual clutter
3. Adjust confirmation points based on market volatility (higher for noisy markets)

## Limitations

- May repaint on current swing points
- Works best in trending conditions
- Requires sufficient historical data for longer swing lengths

This indicator provides a comprehensive view of market structure across multiple timeframes, helping traders make more informed decisions by visualizing the hierarchy of support and resistance levels.
Sürüm Notları
Update Details
1. Fixed Function Overloading Issues
Problem: Pine Script doesn't support multiple functions with the same name ("f_swing_high/low") even if they have different parameters.

Solution: Created unique function names for each timeframe:

f_large_swing_high() / f_large_swing_low() (Structural trends)

f_middle_swing_high() / f_middle_swing_low() (Intermediate trends)

f_small_swing_high() / f_small_swing_low() (Short-term trends)

Benefit: Clearer code organization and no compilation errors.

2. Proper Type Handling for Array Operations
Problem: The original code tried pushing boolean na values into float arrays.

Solution:

Modified pivot functions to explicitly return float(na) instead of boolean na

Added type checks before array operations:


Benefit: Prevents runtime errors and ensures only valid price values are stored.

3. Enhanced Confluence Zone Detection
Improvement: Added multi-timeframe validation for stronger S/R levels:

Visual: Confluence zones plot as semi-transparent colored bands.

4. New Features Added
Price Projections:

Extended dotted lines show where price will reach if the trend continues:

Visual labels appear on breaks of trendlines

Optional audio alerts (configurable in settings):

Pivots now require above-average volume:

5. Optimized Performance
Memory Management:

Used var to persist lines/labels between bars

Added option to show only latest trends (show_last_only)

Reduced Redundancy:

Consolidated duplicate code into reusable functions

Added proper cleanup of old drawing objects

6. Improved Visual Customization
Configurable Elements:

Toggle for confluence zones

MA filter visibility

Label positioning (above/below price)

7. Trading Advantages
Multi-Timeframe Analysis:

See short-term trends in context of larger structure

Confluence zones highlight high-probability reversal areas

Trend Validation:

MA filter prevents counter-trend line drawing

Volume confirmation reduces false signals

Proactive Signals:

Price projections help anticipate future levels

Breakout alerts catch early momentum shifts

This enhanced version provides traders with:
✅ Cleaner code structure
✅ Fewer false signals
✅ Clearer visualization of important levels
✅ Customizable alert conditions
✅ Better performance on large charts

The indicator now offers a complete solution for identifying and trading swing trends across multiple timeframes while maintaining visual clarity.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.