OPEN-SOURCE SCRIPT
تم تحديثه Wolfe Wave Indicator

**Wolfe Wave Indicator Description**
This indicator is a strict Wolfe Wave scanner and trade tracker built for cleaner pattern identification, trade-level plotting, and simple performance tracking.
It detects bullish and bearish Wolfe Wave structures from confirmed pivot highs and lows. A bullish setup requires a five-point sequence where point 3 is lower than point 1, point 5 is lower than point 3, point 4 remains inside the point 1 to point 2 price range, and point 5 forms near the projected point 1 to point 3 line. A bearish setup uses the inverse structure, requiring point 3 above point 1, point 5 above point 3, point 4 inside the point 1 to point 2 range, and point 5 near the projected point 1 to point 3 line.
The pattern begins as a pending Wolfe Wave once the five-point structure is detected. A trade confirms only after price closes back inside the point 1 to point 3 line. The script supports two entry styles: confirmation close or point 4 break. The stop loss is placed beyond point 5, with an optional tick buffer.
Targets are based on the Wolfe Wave EPA line. The EPA line is drawn from point 1 to point 4. TP1, TP2, and TP3 are calculated as user-defined portions or extensions of the distance from entry to the EPA line value at confirmation. By default, TP1 is halfway to the EPA line, TP2 is the EPA line target, and TP3 is an extension beyond the EPA line.
Trades remain open until either the stop loss is hit or TP3 is reached. TP1 and TP2 are tracked as partial target achievements, but they do not close the trade. Stats update only when a trade is fully closed. If the stop and TP3 are both touched on the same candle, the stop has priority.
By default, the indicator allows only one open Wolfe trade at a time. While one trade is open, no new Wolfe pattern will form or confirm. This is intentional and keeps the stats cleaner by avoiding overlapping trade signals. A user toggle is included to allow multiple open trades for those who want to use it more like a pattern scanner.
Visual behavior is simple. Pending patterns are yellow. Confirmed active trades are orange and display entry, stop loss, TP1, TP2, and TP3 levels. Closed historical patterns are purple. A display option allows the EPA line and point 1 to point 3 projection line to appear only on pending or active patterns, keeping historical patterns cleaner and reducing chart clutter.
This indicator is designed as a structured Wolfe Wave trade model, not a loose discretionary drawing tool. It uses strict validation rules, confirmed pivots, defined entry logic, defined stop logic, EPA-based targets, and closed-trade statistics.
This indicator is a strict Wolfe Wave scanner and trade tracker built for cleaner pattern identification, trade-level plotting, and simple performance tracking.
It detects bullish and bearish Wolfe Wave structures from confirmed pivot highs and lows. A bullish setup requires a five-point sequence where point 3 is lower than point 1, point 5 is lower than point 3, point 4 remains inside the point 1 to point 2 price range, and point 5 forms near the projected point 1 to point 3 line. A bearish setup uses the inverse structure, requiring point 3 above point 1, point 5 above point 3, point 4 inside the point 1 to point 2 range, and point 5 near the projected point 1 to point 3 line.
The pattern begins as a pending Wolfe Wave once the five-point structure is detected. A trade confirms only after price closes back inside the point 1 to point 3 line. The script supports two entry styles: confirmation close or point 4 break. The stop loss is placed beyond point 5, with an optional tick buffer.
Targets are based on the Wolfe Wave EPA line. The EPA line is drawn from point 1 to point 4. TP1, TP2, and TP3 are calculated as user-defined portions or extensions of the distance from entry to the EPA line value at confirmation. By default, TP1 is halfway to the EPA line, TP2 is the EPA line target, and TP3 is an extension beyond the EPA line.
Trades remain open until either the stop loss is hit or TP3 is reached. TP1 and TP2 are tracked as partial target achievements, but they do not close the trade. Stats update only when a trade is fully closed. If the stop and TP3 are both touched on the same candle, the stop has priority.
By default, the indicator allows only one open Wolfe trade at a time. While one trade is open, no new Wolfe pattern will form or confirm. This is intentional and keeps the stats cleaner by avoiding overlapping trade signals. A user toggle is included to allow multiple open trades for those who want to use it more like a pattern scanner.
Visual behavior is simple. Pending patterns are yellow. Confirmed active trades are orange and display entry, stop loss, TP1, TP2, and TP3 levels. Closed historical patterns are purple. A display option allows the EPA line and point 1 to point 3 projection line to appear only on pending or active patterns, keeping historical patterns cleaner and reducing chart clutter.
This indicator is designed as a structured Wolfe Wave trade model, not a loose discretionary drawing tool. It uses strict validation rules, confirmed pivots, defined entry logic, defined stop logic, EPA-based targets, and closed-trade statistics.
ملاحظات الأخبار
Wave geometry updated so that only valid Wolfe Wave patterns are found/displayed.ملاحظات الأخبار
## **Update Notes**---
### **Triangle Shading**
Two filled triangles are now drawn directly on each pattern to make the wave geometry easier to read at a glance.
**Shade 1-2-3 Triangle** — toggles the fill covering the area between points 1, 2, and 3. This triangle represents the first half of the wave structure and visually anchors the opening swing. Default on.
**1-2-3 Triangle Color** — color picker for that fill. Defaults to a semi-transparent blue. Adjust the transparency slider to make it more or less prominent without covering the wave lines underneath.
**Shade 3-4-5 Triangle** — toggles the fill covering the area between points 3, 4, and 5. This triangle represents the second half of the structure and highlights the compression zone leading into point 5. Default on.
**3-4-5 Triangle Color** — color picker for that fill. Defaults to a semi-transparent orange. The two triangles using different colors makes it easy to visually distinguish the two halves of the pattern at a glance.
Both triangles respect the pattern's visibility state — they hide automatically on historical patterns when historical display is turned off, and they hide on patterns behind the rewind point when rewind is active.
---
### **Trade Rewind**
A dedicated **Trade Rewind** settings group sits between the Trade group and the Display group. It gives you a clean way to isolate and review any confirmed historical trade without visual interference from everything that came after it.
**Trade Rewind (0 = off)** — integer input, defaults to 0. Set to 1 to focus on the most recent confirmed trade. Set to 2 to step back one further, 3 to go one more, and so on up to a maximum of 50. When you increment this value the chart instantly updates — everything forward of the selected trade disappears and that trade's pattern and levels come into full focus. Set it back to 0 to restore the full chart. This is useful for reviewing past setups, checking whether your levels were respected, or studying the geometry of specific patterns without the noise of what happened next.
**Rewind Pattern Color** — color picker that controls how the selected rewind trade's pattern and wave lines are displayed. Defaults to solid red to make it immediately distinct from both the normal confirmed color (orange) and the historical color (purple). You can set this to any color that works with your chart theme.
When rewind is active the following are hidden: all patterns confirmed after the selected trade, the current pending pattern if one exists, and the current active trade if one is open. Only the selected trade and all patterns that preceded it remain visible, displayed in their normal historical colors.
---
### **Point 4 Retracement Filter**
A dedicated **Point 4 Retracement Filter** settings group sits just above the Trade Rewind group. It adds a structural quality filter at the detection stage, meaning patterns that fail it are never drawn at all — not even as pending.
**Enable Point 4 Retracement Filter** — master toggle for the filter, on by default. When off, no retracement check is performed and detection behaves exactly as it did before this feature was added. When on, the two thresholds below are enforced.
**Min Retracement %** — the minimum percentage of the point 2 to point 3 move that point 4 must retrace. Defaults to 38%, near the Fibonacci 38.2% level. A point 4 that barely retraces — say 15% — indicates a very shallow correction that lacks the structural conviction typical of a quality Wolfe Wave. Raise this value to require deeper retracements and see fewer but potentially higher-quality patterns. Lower it to be more permissive.
**Max Retracement %** — the maximum percentage point 4 may retrace. Defaults to 79%, near the Fibonacci 78.6% level. A point 4 that retraces 95% of the prior leg has nearly fully reversed it, which undermines the wave structure. Lower this value to require tighter retracements. Raise it toward 99% to make the upper bound nearly open.
The retracement is calculated as the absolute distance from point 3 to point 4 divided by the absolute distance from point 2 to point 3, expressed as a percentage. This formula works identically for both bullish and bearish patterns since direction is handled by the structural shape check that runs before it.
A practical way to use this filter is to start with the defaults, run the stats window across a solid historical sample, then tighten the band incrementally — for example moving the min to 50% or the max to 61.8% — and compare the win rates to see whether the stricter criteria genuinely improve results on your instrument and timeframe before committing to tighter settings.
---
### **Default Target Changes**
The default take profit ratios were updated to better reflect realistic target expectations. TP1 moved from 0.5× to 1×, TP2 from 1× to 2×, and TP3 from 1.5× to 3× the EPA distance. The maximum allowed value for all three targets was also raised to 20×, removing the previous hard caps of 2× and 3× for traders who want to run extended targets on higher timeframe setups.
ملاحظات الأخبار
# Wolfe Wave Indicator — Change Log & User Guide---
## **What Changed From The Original**
### **Color System Overhaul**
The original indicator used a single static color for each pattern state regardless of direction. Every confirmed active pattern was orange, every historical pattern was purple, and the rewind was red. You couldn't tell bull from bear at a glance without reading the wave labels.
The updated indicator introduces a direction-aware color system for confirmed active patterns. When a Wolfe Wave confirms and an active trade is open, the wave lines and labels now turn green for bullish patterns and red for bearish patterns automatically. No manual input needed — the color is derived from the pattern's direction at the moment of confirmation.
Pending patterns still draw in yellow while waiting for confirmation. Once confirmed, they switch to green or red. Once closed, they become purple. The rewind color is now orange instead of red, which prevents confusion since red is now reserved exclusively for active bear trades.
---
### **Wave Pattern Colors Group**
All five wave lifecycle colors are now consolidated into a single dedicated settings group called Wave Pattern Colors, instead of being scattered across multiple groups. This makes them easy to find and customize together in one place.
---
### **Historical Patterns Group — Repositioned**
The Historical Patterns group has been moved to sit directly after the Point 4 Retracement Filter in the settings panel. Previously it was buried near the bottom. The color that was inside this group has been moved into the new Wave Pattern Colors group, so Historical Patterns now contains only its toggle and lookback controls.
---
### **Trade Rewind Bug Fix**
The original rewind was broken in a specific way — setting it to 1 would sometimes land on the current open unresolved trade instead of the most recently closed pattern. The rewind now counts backward exclusively through closed patterns, completely ignoring any active open trade. Setting it to 1 always means the most recently closed pattern, 2 means the one before that, and so on.
---
### **Confirmed Pattern Color Input Removed**
The original had a "Confirmed Pattern Color" input that set a single color for all confirmed active patterns regardless of direction. This input has been removed. Confirmed active patterns now always use the bull or bear wave color from the Wave Pattern Colors group automatically.
---
### **Rewind Color Moved and Recolored**
The rewind color input was previously inside the Trade Rewind group. It has been moved into the Wave Pattern Colors group so all wave state colors live in one place. The default color changed from red to orange since red is now used for confirmed bear patterns.
---
## **Updated Input Reference**
### **Wave Pattern Colors**
- **Pending Wave Color** — Default yellow. Controls the color of wave lines and labels while a pattern has been detected but not yet confirmed by price action.
- **Confirmed Bull Wave Color** — Default green. Controls the color of wave lines and labels after a bullish pattern confirms and an active long trade is open.
- **Confirmed Bear Wave Color** — Default red. Controls the color of wave lines and labels after a bearish pattern confirms and an active short trade is open.
- **Historical Wave Color** — Default purple. Controls the color of wave lines and labels for all closed and completed patterns on the chart.
- **Rewind Wave Color** — Default orange. Controls the color of the pattern highlighted when using the Trade Rewind feature.
---
### **Historical Patterns**
- **Show Historical Wolfe Patterns** — Toggles visibility of all closed patterns on the chart. When off, only pending and active patterns are shown.
- **Historical Closed Lookback** — Controls how many closed trades the stats window tracks and includes in its win rate calculations.
---
### **Trade Rewind**
- **Trade Rewind (0 = off)** — Set to 0 to disable. Set to 1 to highlight the most recently closed pattern, 2 for the one before that, and so on. The counter only includes closed patterns — any currently open active trade is ignored entirely.
---
## **How To Use The New Color System**
When you open the indicator settings, go to Wave Pattern Colors to customize how each lifecycle stage appears on your chart. The five states follow a clear visual progression:
**Yellow → Green or Red → Purple**
A pattern starts yellow when first detected. The moment it confirms, it turns green if bullish or red if bearish and your entry, stop, and target levels appear. When the trade closes via stop loss or TP3, it fades to purple and joins the historical record. If you use Trade Rewind to inspect a past closed trade, that pattern displays in orange so it's clearly distinguished from both active and historical patterns at a glance.
The confirmation triangles — the small up and down arrows that appear at the bar where confirmation occurs — use their own separate color inputs called Bull Triangle Color and Bear Triangle Color. These remain in the Display group and are fully independent from the wave line colors, so you can style them differently if preferred.
ملاحظات الأخبار
## Change Log — Wolfe Wave Indicator---
**Removed**
- **Minimum Wave Width Bars** — the raw bar count filter between point 1 and point 5 has been removed entirely. It was context-free, timeframe-unaware, and provided no meaningful geometric constraint. A user switching from a 1-minute to a daily chart was silently running the same bar count against completely different temporal contexts with no warning. The combination of pivot settings and the new symmetry filter makes this fully redundant.
---
**Added**
**Min 1-2 Size (ATR Multiplier)** — default 2.0, sits first in the Pattern group.
This is the primary replacement for the removed wave width input and a meaningful upgrade over it. Rather than counting bars, it measures whether the price swing from point 1 to point 2 is large enough relative to the instrument's current volatility. Specifically it compares the absolute price distance of the 1→2 leg against the ATR value that was in effect when point 2 formed. If the swing doesn't clear the threshold, the pattern is rejected before any other geometry checks run.
At the default of 2.0, the 1→2 leg must span at least two full ATR periods worth of price movement. This automatically tightens on low-volatility instruments and relaxes on high-volatility ones without any manual adjustment. Raise it toward 3.0–4.0 to demand only large, structurally significant waves. Lower it toward 1.0–1.5 to allow smaller waves on quieter instruments or tighter timeframes.
**Min 1-2 ATR Length** — default 14, sits directly under the multiplier.
Controls the lookback period of the ATR used in the above filter. At 14 it measures volatility over the most recent 14 bars, which is the standard baseline. Shorter periods like 7 or 10 make the ATR more reactive to recent volatility spikes, meaning the threshold will tighten quickly after a quiet period and loosen after a volatile one. Longer periods like 20 or 50 smooth the ATR against a broader baseline, making the threshold more stable and less sensitive to short-term volatility shifts. Most users will leave this at 14 unless they have a specific reason to bias toward recent or long-term volatility measurement.
**Enable Symmetry Filter** — default on, sits below the ATR inputs in the Pattern group.
Adds a time-proportionality check between the two halves of the wave. The 3→5 leg is measured in bars and compared to the 1→3 leg in bars. If the ratio falls outside the min/max bounds the pattern is rejected. The core problem this solves is a wave where the first half unfolded over a long period and the second half completed in a fraction of the time — or vice versa. Those patterns look geometrically clean on price but are structurally suspicious because the market's behavior changed dramatically between the two halves. Disable it if you're finding it's rejecting patterns that look valid visually, then widen the ratio range rather than turning it off entirely.
**Min Symmetry Ratio** — default 0.5.
The 3→5 leg must take at least this fraction of the time the 1→3 leg took. At 0.5, a 1→3 leg that took 100 bars requires the 3→5 leg to take at least 50 bars. Lower this toward 0.3 to allow faster completions on the second half, which is common on instruments where momentum accelerates into the final leg. Raise it toward 0.7–0.8 to demand near-equal timing between the two halves.
**Max Symmetry Ratio** — default 1.5.
The 3→5 leg may take at most this multiple of the 1→3 leg. At 1.5, a 1→3 leg that took 100 bars allows the 3→5 leg up to 150 bars. Raise toward 2.0–3.0 if you're seeing valid patterns where the second half grinds out slowly over a much longer period. Lower toward 1.0–1.2 to demand tight time balance between the two halves, which produces the most textbook-looking symmetric waves but will reduce detection frequency.
---
**Unchanged**
All core geometric detection rules, Max 5-Point Line Deviation %, Invalidate Pending On Close Beyond Point 5, Disallow Pattern Overlap, Point 4 Retracement Filter, all Trade group inputs, Trade Rewind, all Display inputs and colors, Stats Window, and all five alert conditions are identical to the original.
ملاحظات الأخبار
**What's New in This Update****A Cleaner, More Intuitive Settings Panel**
In the previous version, all trade-related settings — including entry mode, stop loss buffer, and take profit ratios — were grouped together under a generic label simply called **"Trade."** While functional, this created an awkward overlap with other trade-related groups already in the settings panel, making it less obvious where to look when you wanted to adjust specific things. In this update, that group has been renamed to **"Trade Levels,"** which is a much more accurate and descriptive label for what those settings actually control. Now when you open the settings panel, each group clearly communicates its purpose at a glance — **"Trade Levels"** tells you immediately that this is where you control your entry price, stop loss, and take profit targets. The result is a settings panel that flows more logically from top to bottom, reducing the time you spend hunting for the right input.
**Point 4 Retracement Filter is Now Off by Default**
The Point 4 Retracement Filter is a stricter qualifying rule that requires Point 4 to fall within a specific percentage range of the prior move before the indicator will recognize a pattern. In the previous version this filter was **turned on by default**, which meant new users were unknowingly running a more restrictive version of the indicator without realizing it, potentially missing valid Wolfe Wave setups right out of the box. This update flips it to **off by default**, so the indicator behaves in its most open and responsive state from the moment you add it to your chart. For traders who want that extra layer of filtering, the option is still there — it just no longer assumes you want it without asking.
---
ملاحظات الأخبار
**Wolfe Wave Indicator — Change Log**---
**What This Indicator Does**
This is a pure Wolfe Wave pattern detection tool. It finds valid 5-point Wolfe Wave structures on your chart, draws them, and fires alerts when one is detected. There is no trade logic, no entry signals, no stop losses, no take profits. The indicator simply identifies the pattern and lets you decide what to do with it.
---
**Major Changes From The Original**
The original indicator was built around trade management — it had entry modes, stop loss placement, take profit levels, a trade rewind feature, and a stats window that tracked win rates. All of that has been completely removed. The philosophy behind this version is that the indicator's job is to find the pattern. Everything else is the trader's job.
---
**How Pattern Confirmation Works Now**
This was a fundamental logic fix. In the original, a pattern would sit in a "pending" state after Point 5 formed and wait for price to close back above or below the 1-3 trendline before being considered confirmed. That created a situation where switching entry modes would cause patterns to disappear from the chart entirely, which was wrong.
Now a pattern is confirmed the moment Point 5 is valid and all structural rules pass. There is no pending state. If the 5-point structure is valid, it draws immediately in confirmed colors.
---
**Search Depth**
A new Search Depth input was added, defaulting to 2000 bars. This controls how far back the indicator looks for Wolfe Wave patterns. The underlying indicator call was also updated with `max_bars_back = 2000` so Pine Script actually loads enough historical data to support that search range. Without this, Pine would only calculate as far back as it deemed necessary and potentially miss patterns entirely. Search Depth was moved into the Zigzag group since it directly relates to how pivots are discovered.
---
**What Was Removed**
Quite a lot was stripped out to clean this up:
- The entire trade levels system including entry mode selection, stop buffer ticks, and TP ratio inputs
- The Trade Levels settings group
- The Trade Rewind feature which let you step backward through historical trades
- All open trade tracking, trade management loops, and TP hit history
- The pending pattern invalidation logic that would erase a pattern if price closed beyond Point 5
- The original stats window that showed TP1, TP2, TP3 win rates and closed trade counts
- The "Show Historical Wolfe Patterns" toggle, since the Historical Pattern Lookback number already controls this — setting it to 1 shows only the current pattern, higher numbers show more history
---
**What The Stats Window Shows Now**
The stats window was rebuilt from scratch to show only what's relevant to a pattern-only indicator:
- **Pivot Bars Left** — the current left bar setting used for pivot detection
- **Pivot Bars Right** — the current right bar setting used for pivot detection
- **Search Depth** — how many bars back the indicator is currently scanning
- **Bull Patterns** — count of bullish Wolfe Waves within the historical lookback window
- **Bear Patterns** — count of bearish Wolfe Waves within the historical lookback window
The window remains fully customizable with position, size, and color options.
---
**Display Behavior**
- The most recent pattern always draws in its confirmed bull or bear color — green for bullish, red for bearish
- All older patterns within the lookback window draw in the historical color — purple by default
- Projection lines (EPA and 1-3-5) only show on the most recent pattern, not on historical ones
- Confirmation triangles appear at the Point 5 bar for all patterns within the lookback window
---
**Alerts**
Three alert conditions remain:
- New Wolfe Wave Detected — fires for any direction
- Bullish Wolfe Wave Detected — fires specifically for bullish patterns
- Bearish Wolfe Wave Detected — fires specifically for bearish patterns
All alerts fire the moment Point 5 is confirmed, which is the same moment the pattern draws on chart.
---
**Settings Adjustments Made During Development**
A couple of default values were updated from the original:
- Pivot Bars Left was changed from 5 to 8 to reduce noise
- EPA Projection Bars Forward was changed from 10 to 50 to give the projection lines more visual runway on the chart
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.