OPEN-SOURCE SCRIPT
Wolfe Wave Pattern [UAlgo]

Wolfe Wave Pattern is a pivot based pattern recognition indicator that scans price structure for a five point Wolfe Wave sequence and automatically draws the pattern on the chart once a valid setup is confirmed. The script works directly on price (overlay=true) and is built for visual analysis, giving traders a clear geometric representation of bullish and bearish Wolfe Wave formations with point labels, channel references, and a projected EPA target line.
This implementation uses confirmed swing pivots from TradingView pivot functions as its structural foundation. Every new confirmed pivot is stored, and the script evaluates the most recent five alternating pivots for Wolfe Wave conditions. Instead of trying to detect every possible variation, it applies a practical and consistent ruleset based on swing sequencing, relative highs and lows, convergence of channel lines, and point 5 overshoot behavior beyond the 1 to 3 guide line.
When a valid pattern is found, the script draws the core wave legs (1 to 2, 2 to 3, 3 to 4, 4 to 5), a 2 to 4 channel reference, a 1 to 3 sweet zone guide, and an extended EPA line from 1 to 4 into the future. It also marks the pivot points with labels and triggers an alert message at detection time.
This makes the tool useful for discretionary traders who want a structured way to monitor Wolfe Wave geometry without manually drawing every candidate pattern.
🔹 Features
🔸 1) Pivot Based Wolfe Wave Detection
The script uses ta.pivothigh() and ta.pivotlow() with user configurable left and right bars to build a swing structure map. Each pivot is stored as a custom PivotPoint object containing:
Index of the pivot bar
Pivot price
Pivot type (high or low)
This gives the pattern engine a clean sequence of confirmed turning points rather than raw candle noise.
🔸 2) Automatic Five Point Pattern Recognition
On each newly confirmed pivot, the script checks the most recent five pivots and validates whether they form an alternating sequence suitable for a Wolfe Wave candidate. Only alternating high low high low high or low high low high low structures are considered.
This is an important filter because Wolfe Waves are geometric swing patterns and require clear alternation in pivot direction.
🔸 3) Bullish Wolfe Wave Detection Logic
The bullish model looks for a low high low high low sequence and applies structural and geometric checks, including:
Point 3 below Point 1
Point 4 below Point 2
Point 5 overshooting below the projected 1 to 3 line
Converging channel behavior through slope comparison of 1 to 3 and 2 to 4
This produces a clean descending wedge style candidate that matches the intended bullish Wolfe Wave concept in this implementation.
🔸 4) Bearish Wolfe Wave Detection Logic
The bearish model looks for a high low high low high sequence and applies the inverse logic:
Point 3 above Point 1
Point 4 above Point 2
Point 5 overshooting above the projected 1 to 3 line
Converging channel behavior through slope comparison of 1 to 3 and 2 to 4
This creates a rising wedge style candidate for bearish Wolfe Wave detection.
🔸 5) Full Pattern Drawing on Chart
Once detected, the script draws the pattern directly on price using line objects:
Wave legs 1 to 2, 2 to 3, 3 to 4, and 4 to 5
A 2 to 4 channel reference line
A 1 to 3 sweet zone guide line
An EPA projection line extended from 1 to 4 into future bars
This helps traders quickly inspect geometry and projected target direction without manual plotting.
🔸 6) Point Labels and Pattern Name Display
The indicator labels all five pivot points and positions the labels above or below price depending on pattern direction. This improves readability and makes it easy to verify the sequence visually.
For bullish patterns, low points are labeled below bars and high points above bars. For bearish patterns, the logic is inverted.
🔸 7) EPA Target Projection
The script draws an extended EPA line based on Point 1 and Point 4, projecting it beyond Point 5 to create a visual target path. This offers a practical reference for post detection expectation analysis.
The projection length is proportional to the 1 to 4 horizontal distance, which keeps the target line visually consistent with the pattern scale.
🔸 8) Visual Customization Inputs
Users can customize:
Bullish pattern color
Bearish pattern color
Line width
The script also includes a line style input and line style helper mapping. In the current implementation, core pattern segments are drawn with fixed style choices for visual consistency, while supporting lines use dedicated dashed and arrow styles.
🔸 9) Alert on Detection
When a new bullish or bearish Wolfe Wave is confirmed, the script triggers an alert message at bar close frequency. This allows traders to monitor multiple symbols or timeframes without constantly watching the chart.
🔸 10) Structured Object Design for Maintainability
The script uses custom types for both pivots and patterns:
PivotPoint for swing points
WolfeWave for the full detected pattern including lines, labels, EPA line, and sweet zone line
This object based design keeps the code organized and easier to extend in future versions.
🔹 Calculations
1) Pivot Detection and Storage
The script identifies confirmed swing highs and lows using user defined left and right pivot lengths:
Pine Script®
When a pivot is confirmed, it is stored at the actual pivot bar index (bar_index - lenRight) because pivot confirmation happens after the right side bars are complete:
Pine Script®
The pivot array is capped to a manageable size:
Pine Script®
2) Pattern Scan Trigger and Five Pivot Window
The pattern engine only runs when at least five pivots exist. It then reads the latest five pivots in order:
Pine Script®
The check is gated so the recognition logic processes only when a new pivot has just been confirmed:
Pine Script®
3) Alternation Check
Before applying Wolfe rules, the script requires the five pivots to alternate between highs and lows:
Pine Script®
This prevents invalid sequences such as repeated highs or repeated lows from being treated as pattern candidates.
4) Slope and Projection Utilities
Two helper methods provide the geometric basis of the pattern logic:
Slope between two pivots:
Pine Script®
Projected price of a line at a target bar index:
Pine Script®
These methods are used for overshoot validation, convergence checks, and EPA target projection.
5) Bullish Wolfe Wave Detection Rules
The bullish pattern requires a pivot sequence of:
Point 1 low
Point 2 high
Point 3 low
Point 4 high
Point 5 low
In code, this is checked as:
Pine Script®
Then the script applies structural conditions:
Pine Script®
This enforces a downward contracting structure.
Next, it checks Point 5 overshoot relative to the projected 1 to 3 line at the Point 5 index:
Pine Script®
Finally, it checks convergence using slope comparison:
Pine Script®
Interpretation:
For a bullish setup in this script, both 1 to 3 and 2 to 4 slopes are typically negative, and the 2 to 4 line must descend faster than the 1 to 3 line so the structure converges to the right.
6) Bearish Wolfe Wave Detection Rules
The bearish pattern requires a pivot sequence of:
Point 1 high
Point 2 low
Point 3 high
Point 4 low
Point 5 high
In code:
Pine Script®
Structural conditions:
Pine Script®
This enforces an upward contracting structure.
Point 5 overshoot must be above the projected 1 to 3 line:
Pine Script®
Convergence is then checked using slope comparison:
Pine Script®
Interpretation:
For a bearish setup, both lines are typically rising, and the 2 to 4 line must rise faster than the 1 to 3 line so the wedge contracts to the right.
7) Sweet Zone Guide and Channel Reference
After detection, the script draws a sweet zone guide using the 1 to 3 geometry projected to the Point 5 index:
Pine Script®
It also draws a 2 to 4 reference line as a dashed channel boundary:
Pine Script®
Together, these lines visually frame the Wolfe Wave channel and the Point 5 overshoot area.
8) EPA Line Projection
The EPA line is projected from Point 1 to Point 4 and extended into the future. The horizontal projection length is based on the bar distance from Point 1 to Point 4:
Pine Script®
The EPA line is then drawn with an arrow style:
Pine Script®
This provides a projected target path for the expected move after Point 5.
9) Label Placement Logic
The script places point labels above or below bars based on pattern direction so the labels remain readable and consistent with swing polarity.
For bullish patterns:
Points 1, 3, and 5 are placed below bars
Points 2 and 4 are placed above bars
For bearish patterns:
Points 1, 3, and 5 are placed above bars
Points 2 and 4 are placed below bars
This logic is encoded through direction dependent yloc assignment before creating labels.
10) Detection Object Construction and Drawing
Once a pattern is validated, the script creates a WolfeWave object and calls its draw method:
Pine Script®
The object stores the five pivots, direction, line arrays, label arrays, and special lines (EPA and sweet zone), which makes the implementation modular and easier to manage.
11) Alert Logic
After a bullish or bearish pattern is drawn, the script sends an alert message:
Pine Script®
This allows users to automate notification workflows and review setups only when a complete pattern has been confirmed.
This implementation uses confirmed swing pivots from TradingView pivot functions as its structural foundation. Every new confirmed pivot is stored, and the script evaluates the most recent five alternating pivots for Wolfe Wave conditions. Instead of trying to detect every possible variation, it applies a practical and consistent ruleset based on swing sequencing, relative highs and lows, convergence of channel lines, and point 5 overshoot behavior beyond the 1 to 3 guide line.
When a valid pattern is found, the script draws the core wave legs (1 to 2, 2 to 3, 3 to 4, 4 to 5), a 2 to 4 channel reference, a 1 to 3 sweet zone guide, and an extended EPA line from 1 to 4 into the future. It also marks the pivot points with labels and triggers an alert message at detection time.
This makes the tool useful for discretionary traders who want a structured way to monitor Wolfe Wave geometry without manually drawing every candidate pattern.
🔹 Features
🔸 1) Pivot Based Wolfe Wave Detection
The script uses ta.pivothigh() and ta.pivotlow() with user configurable left and right bars to build a swing structure map. Each pivot is stored as a custom PivotPoint object containing:
Index of the pivot bar
Pivot price
Pivot type (high or low)
This gives the pattern engine a clean sequence of confirmed turning points rather than raw candle noise.
🔸 2) Automatic Five Point Pattern Recognition
On each newly confirmed pivot, the script checks the most recent five pivots and validates whether they form an alternating sequence suitable for a Wolfe Wave candidate. Only alternating high low high low high or low high low high low structures are considered.
This is an important filter because Wolfe Waves are geometric swing patterns and require clear alternation in pivot direction.
🔸 3) Bullish Wolfe Wave Detection Logic
The bullish model looks for a low high low high low sequence and applies structural and geometric checks, including:
Point 3 below Point 1
Point 4 below Point 2
Point 5 overshooting below the projected 1 to 3 line
Converging channel behavior through slope comparison of 1 to 3 and 2 to 4
This produces a clean descending wedge style candidate that matches the intended bullish Wolfe Wave concept in this implementation.
🔸 4) Bearish Wolfe Wave Detection Logic
The bearish model looks for a high low high low high sequence and applies the inverse logic:
Point 3 above Point 1
Point 4 above Point 2
Point 5 overshooting above the projected 1 to 3 line
Converging channel behavior through slope comparison of 1 to 3 and 2 to 4
This creates a rising wedge style candidate for bearish Wolfe Wave detection.
🔸 5) Full Pattern Drawing on Chart
Once detected, the script draws the pattern directly on price using line objects:
Wave legs 1 to 2, 2 to 3, 3 to 4, and 4 to 5
A 2 to 4 channel reference line
A 1 to 3 sweet zone guide line
An EPA projection line extended from 1 to 4 into future bars
This helps traders quickly inspect geometry and projected target direction without manual plotting.
🔸 6) Point Labels and Pattern Name Display
The indicator labels all five pivot points and positions the labels above or below price depending on pattern direction. This improves readability and makes it easy to verify the sequence visually.
For bullish patterns, low points are labeled below bars and high points above bars. For bearish patterns, the logic is inverted.
🔸 7) EPA Target Projection
The script draws an extended EPA line based on Point 1 and Point 4, projecting it beyond Point 5 to create a visual target path. This offers a practical reference for post detection expectation analysis.
The projection length is proportional to the 1 to 4 horizontal distance, which keeps the target line visually consistent with the pattern scale.
🔸 8) Visual Customization Inputs
Users can customize:
Bullish pattern color
Bearish pattern color
Line width
The script also includes a line style input and line style helper mapping. In the current implementation, core pattern segments are drawn with fixed style choices for visual consistency, while supporting lines use dedicated dashed and arrow styles.
🔸 9) Alert on Detection
When a new bullish or bearish Wolfe Wave is confirmed, the script triggers an alert message at bar close frequency. This allows traders to monitor multiple symbols or timeframes without constantly watching the chart.
🔸 10) Structured Object Design for Maintainability
The script uses custom types for both pivots and patterns:
PivotPoint for swing points
WolfeWave for the full detected pattern including lines, labels, EPA line, and sweet zone line
This object based design keeps the code organized and easier to extend in future versions.
🔹 Calculations
1) Pivot Detection and Storage
The script identifies confirmed swing highs and lows using user defined left and right pivot lengths:
When a pivot is confirmed, it is stored at the actual pivot bar index (bar_index - lenRight) because pivot confirmation happens after the right side bars are complete:
The pivot array is capped to a manageable size:
2) Pattern Scan Trigger and Five Pivot Window
The pattern engine only runs when at least five pivots exist. It then reads the latest five pivots in order:
The check is gated so the recognition logic processes only when a new pivot has just been confirmed:
3) Alternation Check
Before applying Wolfe rules, the script requires the five pivots to alternate between highs and lows:
This prevents invalid sequences such as repeated highs or repeated lows from being treated as pattern candidates.
4) Slope and Projection Utilities
Two helper methods provide the geometric basis of the pattern logic:
Slope between two pivots:
Projected price of a line at a target bar index:
These methods are used for overshoot validation, convergence checks, and EPA target projection.
5) Bullish Wolfe Wave Detection Rules
The bullish pattern requires a pivot sequence of:
Point 1 low
Point 2 high
Point 3 low
Point 4 high
Point 5 low
In code, this is checked as:
Then the script applies structural conditions:
This enforces a downward contracting structure.
Next, it checks Point 5 overshoot relative to the projected 1 to 3 line at the Point 5 index:
Finally, it checks convergence using slope comparison:
Interpretation:
For a bullish setup in this script, both 1 to 3 and 2 to 4 slopes are typically negative, and the 2 to 4 line must descend faster than the 1 to 3 line so the structure converges to the right.
6) Bearish Wolfe Wave Detection Rules
The bearish pattern requires a pivot sequence of:
Point 1 high
Point 2 low
Point 3 high
Point 4 low
Point 5 high
In code:
Structural conditions:
This enforces an upward contracting structure.
Point 5 overshoot must be above the projected 1 to 3 line:
Convergence is then checked using slope comparison:
Interpretation:
For a bearish setup, both lines are typically rising, and the 2 to 4 line must rise faster than the 1 to 3 line so the wedge contracts to the right.
7) Sweet Zone Guide and Channel Reference
After detection, the script draws a sweet zone guide using the 1 to 3 geometry projected to the Point 5 index:
It also draws a 2 to 4 reference line as a dashed channel boundary:
Together, these lines visually frame the Wolfe Wave channel and the Point 5 overshoot area.
8) EPA Line Projection
The EPA line is projected from Point 1 to Point 4 and extended into the future. The horizontal projection length is based on the bar distance from Point 1 to Point 4:
The EPA line is then drawn with an arrow style:
This provides a projected target path for the expected move after Point 5.
9) Label Placement Logic
The script places point labels above or below bars based on pattern direction so the labels remain readable and consistent with swing polarity.
For bullish patterns:
Points 1, 3, and 5 are placed below bars
Points 2 and 4 are placed above bars
For bearish patterns:
Points 1, 3, and 5 are placed above bars
Points 2 and 4 are placed below bars
This logic is encoded through direction dependent yloc assignment before creating labels.
10) Detection Object Construction and Drawing
Once a pattern is validated, the script creates a WolfeWave object and calls its draw method:
The object stores the five pivots, direction, line arrays, label arrays, and special lines (EPA and sweet zone), which makes the implementation modular and easier to manage.
11) Alert Logic
After a bullish or bearish pattern is drawn, the script sends an alert message:
This allows users to automate notification workflows and review setups only when a complete pattern has been confirmed.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Get exclusive indicators: pinescriptmarket.com
All content provided by UAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
All content provided by UAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Get exclusive indicators: pinescriptmarket.com
All content provided by UAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
All content provided by UAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.