INVITE-ONLY SCRIPT
تم تحديثه

Smart Levels

165
📊 SMART LEVELS - Dynamic Support & Resistance Indicator

═══════════════════════════════════════════════════════════════

🎯 OVERVIEW

Smart Levels is an advanced support and resistance indicator that automatically identifies and displays the most significant price levels based on historical pivot points. Unlike simple pivot indicators, Smart Levels uses intelligent clustering and weighting algorithms to merge nearby extremums and highlight only the most reliable levels that matter for trading decisions.

This indicator emphasizes identifying key price levels where multiple pivot points converge, creating zones of increased probability for price reactions.

═══════════════════════════════════════════════════════════════

🔧 HOW IT WORKS

1. PIVOT POINT DETECTION

The indicator scans historical price data to identify pivot highs and pivot lows using configurable left/right bar parameters. Each detected extremum represents a potential support or resistance point where price previously reversed.

2. INTELLIGENT LEVEL CLUSTERING

KEY INNOVATION: Instead of drawing a line at every pivot point, Smart Levels uses an ATR-based clustering algorithm to merge nearby extremums into consolidated levels.

• Extremums within a specified percentage of ATR are grouped together
• The level price is calculated as a weighted average of all contributing pivot points
• This eliminates visual clutter and focuses on truly significant zones

3. TOUCH-BASED LEVEL RANKING

Levels are ranked by the number of pivot points (touches) that contributed to them:

• 5+ touches: Strong levels (solid lines, thicker width)
• 2-4 touches: Moderate levels (dashed lines, standard width)
• Only levels meeting the minimum touch threshold are displayed

4. LEVEL CLASSIFICATION

Each level is automatically classified based on the types of extremums it contains:

• 🟢 SUPPORT - Contains only pivot lows (green)
• 🔴 RESISTANCE - Contains only pivot highs (red)
• 🔵 MIRROR LEVEL - Contains both highs and lows, indicating a level that has acted as both support and resistance (blue)

═══════════════════════════════════════════════════════════════

📋 KEY FEATURES

✨ SMART LEVEL DETECTION

• ATR-Adaptive Clustering: Automatically adjusts merge zones based on market volatility
• Configurable History: Look back 50-500 bars to find relevant levels
• Touch-Based Filtering: Only show levels with minimum confirmation (2-10 touches)
• Top N Display: Automatically displays the strongest 3-20 levels to avoid clutter

📊 DETAILED PRICE INFORMATION

• Multi-Line Price Labels: Each level shows ALL contributing pivot prices in a vertical list
• Labels display the exact historical prices that formed the level
• Visual classification icons (↑ support, ↓ resistance, 🔄 mirror)
• Labels positioned to the right of current price for clear visibility

🎨 VISUAL CUSTOMIZATION

• Customizable colors for support, resistance, and mirror levels
• Automatic line styling based on level strength
• Optional debug mode showing all detected pivot points
• Highlight feature that marks which extremums contributed to displayed levels

📈 REAL-TIME UPDATES

• Levels recalculate on every bar for dynamic adaptation
• Lines extend into the future for forward-looking analysis
• Information table shows current ATR, merge zone, and level statistics

═══════════════════════════════════════════════════════════════

⚙️ INPUT PARAMETERS

EXTREMUM DETECTION

• Bars Left (7) - Number of bars to the left for pivot detection (2-20)
• Bars Right (7) - Number of bars to the right for pivot detection (2-20)
• Lookback History (200) - How many bars back to analyze for levels (50-500)

LEVEL SETTINGS

• Merge Percent (0.8% ATR) - Maximum distance to cluster extremums (0.2-3.0%)
• Minimum Touches (2) - Minimum pivot points required to display a level (2-10)
• Maximum Levels (10) - How many top levels to display (3-20)

VISUAL OPTIONS

• Support Color (Green) - Color for support levels
• Resistance Color (Red) - Color for resistance levels
• Mirror Color (Blue) - Color for mirror levels
• Show Debug Pivots - Display all detected pivot points
• Highlight Used Extremums - Mark extremums that form displayed levels

═══════════════════════════════════════════════════════════════

📖 HOW TO USE

BASIC SETUP

1. Add the indicator to your chart (works on any timeframe)
2. Start with default parameters and observe the detected levels
3. Adjust "Minimum Touches" to filter more/less levels
4. Tune "Merge Percent" based on your timeframe and instrument volatility

TRADING APPLICATIONS

1. Entry Timing: Watch for price reactions at identified levels for potential entry points
2. Stop Loss Placement: Place stops beyond strong levels (5+ touches)
3. Target Selection: Use the next significant level as a profit target
4. Breakout Confirmation: Monitor for decisive breaks of strong resistance/support levels
5. Mirror Level Strategy: Blue levels that flip from support to resistance (or vice versa) can provide high-probability setups

INTERPRETATION TIPS

• Solid thick lines (5+ touches) = Extremely reliable levels with strong historical significance
• Dashed lines (2-4 touches) = Valid levels but with less confirmation
• Mirror levels (blue) = Highest probability zones as they've worked in both directions
• Check the price labels to see the exact historical prices that formed each level

RECOMMENDED SETTINGS BY TIMEFRAME

• Scalping (1m-5m): Lookback 100-150, Merge 0.5-0.8%, Min Touches 2-3
• Intraday (15m-1h): Lookback 150-200, Merge 0.8-1.2%, Min Touches 3-4
• Swing (4h-1D): Lookback 200-300, Merge 1.0-1.5%, Min Touches 3-5
• Position (1D-1W): Lookback 300-500, Merge 1.5-2.0%, Min Touches 4-6

═══════════════════════════════════════════════════════════════

🔍 DEBUG FEATURES

Enable the debug options to understand how the indicator works:

• Show Debug Pivots: Displays small triangles at all detected pivot points (faded)
• Highlight Used Extremums: Bright colored triangles show which pivots contributed to displayed levels
• Info Table: Shows current ATR, merge zone size, number of detected extremums, and active levels

These features help you fine-tune parameters and understand why certain levels appear or disappear.

═══════════════════════════════════════════════════════════════

⚡ TECHNICAL DETAILS

• Version: Pine Script v5
• Overlay: Yes (draws directly on price chart)
• Maximum Lines: 50 (configurable limit)
• Maximum Labels: 50 (configurable limit)
• ATR Period: 14 bars (standard volatility measurement)
• Calculation Method: Weighted average of clustered pivot points
• Update Frequency: Every bar (dynamic recalculation)

═══════════════════════════════════════════════════════════════

💡 WHAT MAKES THIS INDICATOR ORIGINAL

1. INTELLIGENT CLUSTERING ALGORITHM
Unlike basic pivot indicators that draw every level, Smart Levels uses ATR-adaptive clustering to merge nearby extremums, highlighting only the most significant zones

2. DETAILED PRICE HISTORY
Multi-line labels show ALL historical prices that formed each level, providing transparency about level formation

3. DYNAMIC STRENGTH VISUALIZATION
Automatic line styling (solid vs dashed, thickness) based on level confirmation strength

4. MIRROR LEVEL DETECTION
Identifies zones that have acted as both support AND resistance, which are statistically more reliable

5. REAL-TIME ADAPTATION
Continuous recalculation ensures levels remain relevant as new price action develops

6. VISUAL DEBUGGING SYSTEM
Comprehensive tools to understand level formation and tune parameters effectively

═══════════════════════════════════════════════════════════════

⚠️ IMPORTANT NOTES

• This indicator identifies historical support/resistance zones - it does NOT predict future price movements
• Always combine with other forms of analysis (trend, volume, fundamentals) for trading decisions
• Levels can break - use proper risk management and stop losses
• Higher timeframes generally produce more reliable levels
• On first load, the indicator needs leftBars + rightBars bars to detect the first pivots

═══════════════════════════════════════════════════════════════

📚 METHODOLOGY BACKGROUND

This indicator implements a clustering-based approach to support and resistance analysis, which emphasizes:

• Identifying price levels where multiple extremums converge
• Focusing on the strongest, most tested levels rather than every minor pivot
• Using historical price behavior to anticipate future support/resistance
• Combining level analysis with proper risk management and position sizing

The clustering approach ensures that levels represent genuine zones of supply/demand accumulation rather than isolated price spikes, making them more reliable for trading decisions.

═══════════════════════════════════════════════════════════════
ملاحظات الأخبار
🆕 NEW FEATURES:
1. Dynamic Merge Zone Range
Old: Single fixed value (0.8% ATR)
New:

Min/Max range (0.1% - 5.0% ATR)
1-5 zones auto-distributed between Min and Max
Flexible sensitivity control

2. Multi-Zone Support
Old: 1 level set only
New: Up to 5 independent level sets simultaneously
3. Enhanced Color System
Old: 3 colors (Support/Resistance/Mirror)
New: 15 colors (3 per zone × 5 zones)

Each zone has distinct color scheme
Easy visual differentiation

4. Touch Price Labels
New Feature:

Shows actual price at each level touch
Positioned above/below bars at extremums
Size options: Tiny/Small/Normal/Large
Color modes: Level Color or Custom
Toggle on/off

5. Cleaner Interface
Old: Statistics table on chart
New: Table removed for clean visualization
6. Zone Markers
New: Each level labeled as Z1-Z5 for easy identification
📊 PRESERVED:

Pivot point detection
ATR-based level clustering
Touch count filtering
Strength-based sorting
Level types (Support/Resistance/Mirror)
Debug mode with pivot highlighting

🎯 KEY BENEFITS:

Multi-timeframe analysis in single view
Precise entries with touch price markers
Adaptive range (0.1%-5% ATR) for any volatility
Visual clarity with color-coded zones
Scalable from minimal (1 zone) to complex (5 zones)
ملاحظات الأخبار
🆕 NEW FEATURES:
1. Dynamic Merge Zone Range
Old: Single fixed value (0.8% ATR)
New:

Min/Max range (0.1% - 5.0% ATR)
1-5 zones auto-distributed between Min and Max
Flexible sensitivity control

2. Multi-Zone Support
Old: 1 level set only
New: Up to 5 independent level sets simultaneously
3. Enhanced Color System
Old: 3 colors (Support/Resistance/Mirror)
New: 15 colors (3 per zone × 5 zones)

Each zone has distinct color scheme
Easy visual differentiation

4. Touch Price Labels
New Feature:

Shows actual price at each level touch
Positioned above/below bars at extremums
Size options: Tiny/Small/Normal/Large
Color modes: Level Color or Custom
Toggle on/off

5. Cleaner Interface
Old: Statistics table on chart
New: Table removed for clean visualization
6. Zone Markers
New: Each level labeled as Z1-Z5 for easy identification
📊 PRESERVED:

Pivot point detection
ATR-based level clustering
Touch count filtering
Strength-based sorting
Level types (Support/Resistance/Mirror)
Debug mode with pivot highlighting

🎯 KEY BENEFITS:

Multi-timeframe analysis in single view
Precise entries with touch price markers
Adaptive range (0.1%-5% ATR) for any volatility
Visual clarity with color-coded zones
Scalable from minimal (1 zone) to complex (5 zones)

إخلاء المسؤولية

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.