OPEN-SOURCE SCRIPT

Structural Pivot Mapper [JOAT]

5 297
Structural Pivot Mapper [JOAT]

Introduction

The Structural Pivot Mapper (SPM) is an advanced open-source structural analysis indicator that combines W/M pattern detection, dynamic support/resistance level mapping, pivot point analysis, volume profile integration, and break-retest detection to identify institutional structural pivots and key price levels. This indicator reveals market structure through systematic detection of swing highs/lows, classical chart patterns, and volume-based price levels, providing traders with a comprehensive structural framework for identifying high-probability entry and exit zones.

Unlike basic pivot indicators that simply mark swing points, SPM employs sophisticated pattern recognition algorithms to detect W patterns (bullish reversal), M patterns (bearish reversal), Head & Shoulders formations, and tracks level strength through touch counting and volume analysis. The indicator automatically manages support/resistance levels, removes outdated levels, and highlights Point of Control (POC) from volume profile analysis to show where institutional activity is concentrated.

스냅샷

Why This Indicator Exists

This indicator addresses the challenge of identifying key structural levels where institutional players are likely to defend positions or initiate new trades. Market structure provides the framework for understanding price behavior, and SPM systematically reveals:

  • W/M Pattern Detection: Identifies classical reversal patterns with strict validation rules
  • Dynamic Support/Resistance: Tracks pivot-based levels with automatic strength scoring
  • Level Touch Counting: Quantifies level importance through historical price interaction
  • Volume Profile Integration: Identifies Point of Control (POC) where maximum volume traded
  • Break & Retest Detection: Monitors level breaks and subsequent retests for confirmation
  • Head & Shoulders Patterns: Detects both regular and inverse H&S formations
  • Smart Level Management: Automatically removes weak levels and maintains only strongest


Each component provides unique intelligence. W/M patterns show reversal zones, pivots show swing structure, touch counting shows level strength, volume profile shows institutional interest, break-retest confirms level validity, and H&S patterns show major reversals.

Core Components Explained

1. W Pattern Detection (Bullish Reversal)

SPM detects W patterns through systematic analysis of 5 pivot points (A-B-C-D-E):

Pine Script®


W patterns indicate bullish reversal when:
- Price forms double bottom (D and B)
- Middle high (C) is lower than current price (E)
- Second low (B) is higher than or equal to first low (D) in strict mode
- Pattern completes with breakout above middle high (C)

Entry level is at middle high (C), stop loss at second low (B).

2. M Pattern Detection (Bearish Reversal)

M patterns are detected through inverted W logic:

Pine Script®


M patterns indicate bearish reversal when:
- Price forms double top (D and B)
- Middle low (C) is higher than current price (E)
- Second high (B) is lower than or equal to first high (D) in strict mode
- Pattern completes with breakdown below middle low (C)

Entry level is at middle low (C), stop loss at second high (B).

3. Dynamic Support/Resistance Level Management

SPM tracks pivot-based support and resistance levels with automatic management:

Pine Script®


Level strength is calculated through touch counting:
  • 1 touch: New level (weak)
  • 2 touches: Confirmed level (moderate)
  • 3+ touches: Strong level (high importance)


Levels are automatically removed when max_levels is reached and auto_cleanup is enabled.

스냅샷

4. Level Touch Counting & Strength Scoring

SPM tracks how many times price interacts with each level:

Pine Script®


Strength score (0-100) is calculated based on:
  • Touch Count (0-40 points): More touches = stronger level (8 points per touch, max 40)
  • Age Factor (0-30 points): Older levels = more established (based on level_strength_period)
  • Volume Factor (0-30 points): Higher volume at level = more institutional interest


Only levels with 2+ touches and strength >60 are displayed to reduce clutter.

5. Volume Profile & Point of Control (POC)

SPM calculates volume profile to identify price levels with maximum trading activity:

Pine Script®


POC represents the price level where most volume traded - typically where institutions have significant positions. Value Area High (VAH) and Value Area Low (VAL) define the range containing 70% of volume.

6. Break & Retest Detection

SPM monitors when price breaks through resistance levels and subsequently retests:

Pine Script®


Successful retests confirm level validity and often provide high-probability entry opportunities.

7. Head & Shoulders Pattern Detection

SPM detects both regular and inverse Head & Shoulders formations:

Pine Script®


H&S patterns are major reversal formations indicating trend exhaustion and potential reversal.

Visual Elements

  • Support Lines: Blue horizontal lines with strength-based width (2-3px)
  • Resistance Lines: Pink horizontal lines with strength-based width (2-3px)
  • Level Labels: "S: price [Nx]" for support, "R: price [Nx]" for resistance (N = touch count)
  • Pivot Markers: Small circles at swing highs (pink) and lows (blue)
  • POC Line: Yellow dotted line showing Point of Control from volume profile
  • Retest Markers: "RT" labels when price retests broken levels
  • Pattern Lines: Optional dashed lines showing W/M pattern structure (disabled by default)
  • Dashboard: Real-time metrics showing resistance count, support count, pattern status, POC price


Input Parameters

Pattern Detection:
  • Pattern Range: Lookback period for W/M detection (default: 9)
  • Pattern Offset: Additional bars to check (default: 0)
  • Strict Pattern Validation: Enforce stricter pattern rules (default: false)


Pivot Settings:
  • Pivot Left Bars: Bars to left of pivot (default: 6)
  • Pivot Right Bars: Bars to right of pivot (default: 1)
  • Show Pivot Labels: Toggle pivot markers (default: true)


Level Management:
  • Maximum Levels: Max support/resistance levels to track (default: 3)
  • Level Strength Period: Lookback for strength calculation (default: 50)
  • Auto-Cleanup Old Levels: Remove oldest when max reached (default: true)


Visualization:
  • Show Support/Resistance Zones: Toggle level display (default: true)
  • Zone Width (ATR %): Width of level zones (default: 0.5)
  • Show Pattern Lines: Toggle W/M pattern visualization (default: false)


스냅샷

How to Use This Indicator

Step 1: Identify Key Structural Levels
Look for blue (support) and pink (resistance) lines. Thicker lines with higher touch counts [3x+] are strongest.

Step 2: Monitor Pattern Formations
Watch dashboard for "W Pattern" (bullish) or "M Pattern" (bearish) status. These indicate potential reversal zones.

Step 3: Check POC Proximity
Yellow POC line shows where maximum volume traded. Price often gravitates toward POC or bounces from it.

Step 4: Wait for Break & Retest
When price breaks resistance and retests (RT label), it confirms level as new support. High-probability long entry.

Step 5: Use Level Strength for Confidence
Levels with 3+ touches are most reliable. Dashboard shows total support/resistance count.

Step 6: Combine with Higher Timeframe Structure
Use SPM on multiple timeframes. Daily/weekly levels are stronger than intraday levels.

Best Practices

  • Focus on levels with 3+ touches - these have proven institutional interest
  • W/M patterns work best at major support/resistance levels
  • POC acts as magnet - price often returns to POC after deviating
  • Break-retest setups have highest win rate when combined with volume confirmation
  • Disable pattern lines to reduce chart clutter - use dashboard for pattern status
  • Adjust zone width based on instrument volatility (higher ATR = wider zones)
  • Auto-cleanup keeps chart clean but may remove valid older levels
  • H&S patterns are most reliable on higher timeframes (4H+)
  • Level strength score >70 indicates institutional-grade level
  • Smart spacing prevents overlapping levels - only strongest levels shown


Indicator Limitations

  • Pattern detection requires sufficient historical data and clear pivot formation
  • W/M patterns can produce false signals during strong trends
  • Level touch counting is historical - doesn't predict future touches
  • Volume profile requires consistent volume data - may not work on illiquid instruments
  • Break-retest detection has time window (3-20 bars) - may miss delayed retests
  • Maximum level limit means some valid levels may be removed
  • Pivot detection lags by pivot_right bars - not real-time
  • H&S patterns are rare and require specific market conditions
  • Level strength scoring is multi-factor but still subjective
  • Smart spacing may hide valid levels that are too close to stronger levels


Technical Implementation

Built with Pine Script v6 using:
  • Custom W/M pattern detection with 5-point validation
  • Pivot-based support/resistance tracking with arrays
  • Touch counting system with ATR-based zone detection
  • Multi-factor level strength scoring (touches + age + volume)
  • Volume profile calculation with 20-bin price distribution
  • POC detection through maximum volume identification
  • Break-retest monitoring with time window validation
  • Head & Shoulders pattern detection (regular and inverse)
  • Smart level spacing to prevent overlapping (1.5 ATR minimum)
  • Automatic level cleanup when maximum reached
  • Dynamic line and label management to prevent memory issues
  • Real-time dashboard with 4 key metrics


The code is fully open-source and can be modified to suit individual trading styles.

Originality Statement

This indicator is original in its comprehensive structural analysis approach. While pivot detection and pattern recognition are established concepts, this indicator is justified because:

  • It combines W/M pattern detection with dynamic support/resistance management in a unified system
  • The multi-factor level strength scoring (touches + age + volume) provides quantitative level assessment
  • Volume profile integration with POC detection adds institutional perspective to structural analysis
  • Break-retest detection with time window validation automates a manual trading technique
  • Smart level spacing prevents chart clutter while maintaining strongest levels
  • Head & Shoulders detection (both regular and inverse) adds major reversal pattern recognition
  • Automatic level cleanup maintains chart readability without manual intervention
  • Integration of classical patterns (W/M, H&S) with modern volume analysis creates layered confirmation


Each component contributes unique information: W/M patterns show reversals, pivots show structure, touch counting shows strength, volume profile shows institutional interest, break-retest confirms validity, H&S shows major reversals, and strength scoring quantifies importance. The indicator's value lies in presenting these complementary perspectives simultaneously with intelligent level management.

Disclaimer

This indicator is provided for educational and informational purposes only. It is not financial advice. Structural levels and patterns do not guarantee price behavior. Trading involves substantial risk of loss. Past performance does not guarantee future results. Always use proper risk management and never risk more than you can afford to lose.

-Made with passion by officialjackofalltrades

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.