Elliott Wave (Experimental) [UAlgo]Elliott Wave (Experimental) is an automated swing based Elliott Wave scanner that attempts to classify recent market structure into common motive and corrective wave patterns. The script first converts price into a cleaned swing sequence using pivot confirmation and a minimum swing percentage filter. It then runs a two pass detection process that prioritizes five wave patterns first and fills remaining gaps with three wave corrective structures. Each detected pattern is validated with a rule engine, assigned a confidence score using Fibonacci ratio proximity, and rendered on the chart with wave labels, wave lines, optional channels, and optional Fibonacci projection targets.
This indicator is labeled experimental by design. Elliott Wave interpretation is inherently probabilistic and can vary between analysts, so the script focuses on transparent, rule driven validation and a confidence model that helps you judge the quality of each detected structure. Instead of presenting a single rigid count, it can render multiple detected patterns in the swing history and then highlights the latest one in a dashboard with direction, confidence, rule pass ratio, and a next target estimate.
🔹 Features
1) Swing Engine with Pivot Confirmation and Minimum Move Filter
The foundation of the scanner is a zigzag style swing engine. Swings are built from pivot highs and pivot lows confirmed by a configurable lookback. A Min Swing percent filter ensures that only meaningful moves are added as new swings. When consecutive pivots of the same type appear, the engine keeps only the better extreme, which helps reduce noise.
This creates a stable swing sequence that becomes the input for all wave pattern validators.
2) Multiple Pattern Families Supported
The scanner supports a wide set of Elliott structures, each enabled or disabled by inputs:
Impulse 1 2 3 4 5
Diagonal leading or ending with contracting or expanding classification
Zigzag ABC with a 5 3 5 style model
Flat ABC with regular expanded and running classification
Triangle ABCDE with contracting or expanding detection
Combination WXY for double three style sequences
Because patterns can overlap, the script uses a two pass orchestration that gives five wave structures priority, then looks for three wave structures in unused swing segments.
3) Rule Engine with Transparent Results
Each validator returns a WavePattern object that contains:
Wave list with labeled segments
A pattern type tag
Direction bullish or bearish
Validation state
Confidence score
Detailed rule results with pass and fail status and descriptive text
Rules implement common academic guidelines, such as Wave 2 not exceeding Wave 1 origin, Wave 3 not being the shortest, diagonal overlap behavior, and triangle containment conditions.
A relaxed overlap option can be enabled to allow minor Wave 4 overlap into Wave 1 territory when analyzing leveraged or futures markets where strict cash market rules may be less reliable.
4) Fibonacci Based Confidence Scoring
When a pattern passes its core rules, it receives a confidence score based on how close key measured ratios are to common Fibonacci ideals. The score is designed to reward clean proportionality and alternation behavior, while penalizing overlap or weak impulse characteristics.
Confidence is shown in the dashboard and is also mapped to a color for fast interpretation.
5) Rich Chart Rendering with Optional Components
Detected patterns can render several layers of visuals:
Wave lines connecting swing points
Wave labels placed above highs and below lows
Optional wave channel for motive patterns
Optional Fibonacci projection levels with labels
A developing dashed leg from the last confirmed swing to the current bar to indicate the incomplete swing path
A dotted background zigzag to show the underlying swing structure that drives detection
All drawings are rebuilt on the last bar to keep the chart clean and ensure only the current best set of objects remains visible.
6) Fibonacci Projection Engine for Next Targets
The script generates forward projection levels based on pattern type:
After an impulse, it projects common correction retracement levels of the full impulse
After ABC patterns, it projects trend resumption extensions based on Wave A length
After triangles, it projects post triangle thrust targets
The first projection is used as the next target value in the dashboard.
7) Dashboard Summary for the Latest Pattern
A compact dashboard shows the latest detected pattern with:
Pattern name
Direction
Confidence percent
Active wave label
Rules passed count over total rules
Next target from the projection list
Patterns found count and total swings count
This dashboard is designed to provide a quick situational read without requiring you to inspect every label and line manually.
🔹 Calculations
1) Swing Detection and State Management
Swings are detected using pivot highs and lows with symmetric confirmation:
float ph = ta.pivothigh(high, i_pLen, i_pLen)
float pl = ta.pivotlow(low, i_pLen, i_pLen)
When a pivot is found, a WavePoint is constructed at the pivot bar index and time, then passed into the swing engine. The engine enforces alternation and minimum percent change:
If the new pivot is the same type as the last swing, the more extreme point replaces it
If the pivot is the opposite type, it is only accepted if percent change exceeds Min Swing percent
This percent change filter is computed as:
absolute difference between swing prices divided by last swing price times 100
The swing list is capped to a maximum size to limit memory and improve stability.
2) Two Pass Pattern Orchestration with Segment Claiming
The scanner evaluates swing sequences and constructs patterns in two passes:
Pass 1 scans for five wave patterns such as impulse diagonal and triangle. If a valid pattern is found, its swing segment is marked as used so later scans do not overlap it.
Pass 2 scans the remaining unused segments for three wave patterns such as zigzag flat and combination.
This approach reduces overlapping detections and prioritizes larger motive structures.
3) Impulse Validation Rules and Measurements
Impulse detection uses six swing points p0 through p5, producing five waves. It validates:
Wave 2 does not retrace beyond Wave 1 origin
Wave 3 is not the shortest among Waves 1 3 5
Wave 4 does not overlap Wave 1 territory unless relaxed mode is enabled
Wave 3 exceeds the end of Wave 1
Wave 5 generally progresses beyond Wave 3 with tolerance for truncation strength
Wave 3 shows impulse like momentum using a slope proxy based on wave length divided by bar length
Wave ratios are then computed for confidence scoring:
Wave 2 retracement relative to Wave 1
Wave 3 extension relative to Wave 1
Wave 4 retracement relative to Wave 3
Wave 5 extension relative to Wave 3
Wave 5 equality relative to Wave 1
Fibonacci closeness is computed by measuring distance to a list of ideal ratios and converting it into a percent score.
4) Diagonal Validation and Contracting Expanding Classification
Diagonal validation also uses six points. It enforces overlap between Wave 4 and Wave 1 as a defining feature, plus containment rules and the requirement that Wave 5 exceeds Wave 3. It then classifies:
Contracting diagonal when wave lengths shrink in a structured way
Expanding diagonal when wave lengths grow in a structured way
A confidence score is computed using retracement ratios and a momentum decrease check for contracting diagonals.
5) Corrective Pattern Validators
Zigzag ABC validator checks:
Wave B does not exceed Wave A origin
Wave A has a stronger slope than Wave B as an impulse proxy
Wave C ends beyond Wave A
Wave B retracement remains within a tolerance range
Flat ABC validator checks:
Wave B retraces at least 90 percent of Wave A
Classifies regular expanded or running based on whether B exceeds the origin and whether C exceeds A
Requires C to reach or exceed A for regular and expanded cases
Triangle ABCDE validator checks:
Contracting triangle containment of C within A D within B and E within C plus shrinking wave sizes
Expanding triangle growth conditions
Corrective character proxy based on overlap
Combination WXY validator checks:
X does not exceed W origin
W is not triangle like using a size relationship proxy
W and Y proportionality and sideways character checks
X retracement within corrective bounds
Each validator returns rule results and a confidence score when valid.
6) Fibonacci Projection Logic
After detection, the script adds projections to the latest pattern:
For impulse patterns, it projects correction retracement levels of the full impulse: 38.2 percent, 50 percent, 61.8 percent
For ABC patterns, it projects 100 percent and 161.8 percent extensions based on Wave A length
For triangles, it projects thrust targets based on Wave A length
Projection prices are computed by adding or subtracting a multiple of a reference wave length from the last wave end price, depending on detected direction.
7) Rendering and Object Management
On the last bar, the script deletes previous drawing objects and renders the current scan results. Rendering includes:
Wave lines with motive waves in bullish or bearish color and corrective waves in corrective color
Wave labels placed above highs and below lows
Optional wave channel using the wave 2 to wave 4 line and a parallel through wave 3
Fibonacci projection lines and labels extending forward
A developing dashed leg from last confirmed swing to current price proxy
A dotted zigzag reference connecting all swings
This ensures the chart remains responsive and avoids accumulating outdated drawings.
Pine Script® indicator


















