OPEN-SOURCE SCRIPT
Real Elliott Wave [MarketFragments]

Real Elliott Wave [MarketFragments]
A top-down Elliott Wave labeler for TradingView. Instead of forcing a count one
swing at a time, it frames the single dominant swing inside a window of the
last N bars and decomposes it into a 1-2-3-4-5 impulse and an A-B-C correction.
The same decomposition is recursed into every leg to draw minor and micro
sub-waves, and a confidence score grades how well the structure obeys the
classic Elliott rules. Labels are computed at the right edge and frozen, so
historical labels do not repaint.
Open-source. Free for public use.
─────────────────────────────────────────────────────────────
WHAT MAKES THIS DIFFERENT
─────────────────────────────────────────────────────────────
Most free Elliott Wave scripts are bottom-up zigzag counters: they walk pivot
to pivot and slap 1-2-3-4-5 onto whatever swings appear. That approach forces
wave 3 onto a single swing (so it can rarely be the longest), produces fragile
A-B-C counts, and tends to repaint as pivots reshuffle.
This one is built differently:
-- TRUE TOP-DOWN FRAMING. It first isolates the dominant swing in the window,
then decomposes THAT swing -- so wave 3 can legitimately span many smaller
swings and become the longest wave, the way real impulses look.
-- NON-REPAINTING LABELS. Every pivot is resolved at the right edge and frozen
at a fixed bar. Closed history does not redraw on reload.
-- FRACTAL RECURSION. The exact same engine that builds the major count is
reused inside every leg for minor (i-v / a-b-c) and micro sub-waves -- one
consistent method at every degree, not a separate hand-tuned heuristic.
-- CONFIDENCE SCORING. A live read on how many of the seven Elliott structural
rules the current count satisfies, so you know whether to trust it.
-- COLLAPSE-PROOF ZONES. Waves 2 and 4 are searched strictly between their
neighbors, so two pivots can never land on the same candle.
─────────────────────────────────────────────────────────────
HOW IT WORKS
─────────────────────────────────────────────────────────────
LAYER 1 -- WINDOW FRAME
The script looks only at the last `lookback` bars (default 100). Inside that
window it finds the highest high and the lowest low and decides direction: if
the low is older than the high the dominant move is UP, otherwise DOWN. The
earlier extreme becomes the ORIGIN (O), the later extreme becomes the END (E).
Everything that follows is a decomposition of that one O -> E swing -- which is
why the window is the master control: it decides which swing gets counted.
LAYER 2 -- ZONE-BASED 1-2-3-4-5 DECOMPOSITION
The O -> E leg is split into five waves using non-overlapping search zones
rather than a swing-by-swing loop:
Wave 1 Trend-direction extreme in the first w1ZonePct% of the leg (def 35%)
Wave 3 Trend-direction extreme between w1ZonePct% and w3ZonePct% (def 35-70%)
Wave 2 Counter-trend pullback extreme STRICTLY between wave 1 and wave 3
Wave 4 Counter-trend pullback extreme STRICTLY between wave 3 and E
Wave 5 The end of the leg (E itself)
Because wave 3 is searched across the middle band of the whole leg, it can
span many smaller swings and become the longest wave. The strict "between"
rule on waves 2 and 4 prevents the common failure where two pivots share a bar.
LAYER 3 -- A-B-C CORRECTION
After wave 5, the post-5 leg is scanned for the correction. Wave A is found
first (the first reversal extreme in the first abcAzone% of the post-5 leg),
then C (the correction extreme after A), then B (the bounce strictly between A
and C). If the correction has not developed enough bars, C is not drawn as a
confirmed pivot -- instead a projected target labeled "C?" is shown at the
right edge so you can see where the correction is aiming.
LAYER 4 -- MINOR AND MICRO SUB-WAVES (FRACTAL NESTING)
Once the major pivots exist, the same decomposition is applied inside each leg:
Motive legs (0-1, 2-3, 4-5, motive correction legs) -> minor i-ii-iii-iv-v
Corrective legs (1-2, 3-4, A-B) -> minor a-b-c
Turning on Micro subdivides wave 3's motive sub-legs one degree further into
(i)-(iv). Legs shorter than `minorMinBars` are left unlabeled, because a leg
too short to hold a real sub-pattern should not be cluttered with one.
LAYER 5 -- CONFIDENCE SCORE
The count is graded against seven structural Elliott rules:
1 Wave 1 moves in the trend direction
2 Wave 2 does not pass the origin
3 Wave 2 stays inside wave 1
4 Wave 3 exceeds wave 1
5 Wave 4 stays inside wave 3
6 Wave 4 does not overlap wave 2
7 Wave 5 exceeds wave 4
The confidence % is built from how many of the seven rules hold, with a bonus
when wave 3 is the longest wave. The status label colors the result green
(strong), yellow (plausible), or orange (the window probably does not hold one
clean impulse).
─────────────────────────────────────────────────────────────
WHAT YOU SEE ON THE CHART
─────────────────────────────────────────────────────────────
Major 0-1-2-3-4-5 Aqua bubbles -- the dominant impulse
Major A-B-C Purple bubbles -- the correction after wave 5
"C?" Gray bubble at the right edge -- projected, not yet formed
Minor i-v Gray -- a motive leg subdivided
Minor a-b-c Silver -- a corrective leg subdivided
Micro (i)-(iv) Dark gray -- 3rd-degree detail inside wave 3 (optional)
Status label Top-left -- direction (UP/DN), confidence %, rules met /7,
whether wave 3 is the longest, slope bias, and window size
All label colors are configurable in the indicator's Colors settings group.
─────────────────────────────────────────────────────────────
HOW TO USE -- READING CONFIDENCE AND TUNING
─────────────────────────────────────────────────────────────
The label is only as good as the window it is reading. If the confidence is
low or the count looks wrong, tune it in this order:
1 ADJUST THE WINDOW FIRST.
Change `lookback` so the window frames ONE clean swing. Too large and it
spans several patterns (confidence drops); too small and there is no room
for five waves. Sweep 200 / 350 / 500 / 1000 and keep the best confidence %.
2 IF THE WINDOW ALONE WON'T REACH 100%, ADJUST THE PIVOT (ZONE) LENGTHS.
`w1ZonePct` and `w3ZonePct` move where waves 1 and 3 are searched, and
`abcAzone` moves where wave A is searched. Make small changes and re-check
the confidence % after each one.
3 CONTROL CLUTTER.
`minSep` and `minorMinBars` decide how much sub-structure is drawn. Raise
them to de-clutter; lower them to label shorter legs.
Color guide: green (>=75) trust it, yellow (55-74) plausible, orange (<55)
re-frame the window before reading anything into the count.
─────────────────────────────────────────────────────────────
INPUTS
─────────────────────────────────────────────────────────────
Lookback (window bars) 100 Analysis window in bars -- THE main knob
Wave-1 zone % 35 Wave 1 searched in the first N% of the leg
Wave-3 zone % 70 Wave 3 searched between Wave-1 zone% and this %
Wave-A zone % 40 Wave A searched in the first N% of the post-5 leg
Min bars A/B/C "formed" 4 Min bars between A/B/C to confirm (else "C?")
Min leg bars for minor 4 Min leg length before minor labels are drawn
Detect A-B-C on Detect and label the A-B-C correction
Minor sub-waves on Draw minor sub-waves (i-v / a-b-c)
Micro (3rd degree) off Draw micro detail inside wave 3
Show status label on Show the direction / confidence label
Slope length 13 Length for the status slope-bias readout
PERFORMANCE: a heavy configuration (minor + micro on a large window) makes the
script do more work. If it lags, turn Micro OFF first, then lower `lookback`.
─────────────────────────────────────────────────────────────
IMPORTANT NOTES
─────────────────────────────────────────────────────────────
-- This is the FIRST version. Additional minor cycles and refinements will be
added in future releases.
-- Suggestions are welcome -- comment below with what you would like adjusted
in the next version.
-- The wave-decomposition pathway was verified in Python before being ported
to Pine.
-- This is a labels-only tool. It is NOT an entry or exit signal.
-- Like any "last-N-bars" analysis, the developing right edge can shift as new
bars arrive while the window slides; closed history is stable on reload.
-- This indicator has not been backtested or forward tested as a trading system.
-- This is not financial advice.
-- Trading involves substantial risk of loss.
-- Use for educational and research purposes only.
─────────────────────────────────────────────────────────────
Open-source -- Free for public use
─────────────────────────────────────────────────────────────
A top-down Elliott Wave labeler for TradingView. Instead of forcing a count one
swing at a time, it frames the single dominant swing inside a window of the
last N bars and decomposes it into a 1-2-3-4-5 impulse and an A-B-C correction.
The same decomposition is recursed into every leg to draw minor and micro
sub-waves, and a confidence score grades how well the structure obeys the
classic Elliott rules. Labels are computed at the right edge and frozen, so
historical labels do not repaint.
Open-source. Free for public use.
─────────────────────────────────────────────────────────────
WHAT MAKES THIS DIFFERENT
─────────────────────────────────────────────────────────────
Most free Elliott Wave scripts are bottom-up zigzag counters: they walk pivot
to pivot and slap 1-2-3-4-5 onto whatever swings appear. That approach forces
wave 3 onto a single swing (so it can rarely be the longest), produces fragile
A-B-C counts, and tends to repaint as pivots reshuffle.
This one is built differently:
-- TRUE TOP-DOWN FRAMING. It first isolates the dominant swing in the window,
then decomposes THAT swing -- so wave 3 can legitimately span many smaller
swings and become the longest wave, the way real impulses look.
-- NON-REPAINTING LABELS. Every pivot is resolved at the right edge and frozen
at a fixed bar. Closed history does not redraw on reload.
-- FRACTAL RECURSION. The exact same engine that builds the major count is
reused inside every leg for minor (i-v / a-b-c) and micro sub-waves -- one
consistent method at every degree, not a separate hand-tuned heuristic.
-- CONFIDENCE SCORING. A live read on how many of the seven Elliott structural
rules the current count satisfies, so you know whether to trust it.
-- COLLAPSE-PROOF ZONES. Waves 2 and 4 are searched strictly between their
neighbors, so two pivots can never land on the same candle.
─────────────────────────────────────────────────────────────
HOW IT WORKS
─────────────────────────────────────────────────────────────
LAYER 1 -- WINDOW FRAME
The script looks only at the last `lookback` bars (default 100). Inside that
window it finds the highest high and the lowest low and decides direction: if
the low is older than the high the dominant move is UP, otherwise DOWN. The
earlier extreme becomes the ORIGIN (O), the later extreme becomes the END (E).
Everything that follows is a decomposition of that one O -> E swing -- which is
why the window is the master control: it decides which swing gets counted.
LAYER 2 -- ZONE-BASED 1-2-3-4-5 DECOMPOSITION
The O -> E leg is split into five waves using non-overlapping search zones
rather than a swing-by-swing loop:
Wave 1 Trend-direction extreme in the first w1ZonePct% of the leg (def 35%)
Wave 3 Trend-direction extreme between w1ZonePct% and w3ZonePct% (def 35-70%)
Wave 2 Counter-trend pullback extreme STRICTLY between wave 1 and wave 3
Wave 4 Counter-trend pullback extreme STRICTLY between wave 3 and E
Wave 5 The end of the leg (E itself)
Because wave 3 is searched across the middle band of the whole leg, it can
span many smaller swings and become the longest wave. The strict "between"
rule on waves 2 and 4 prevents the common failure where two pivots share a bar.
LAYER 3 -- A-B-C CORRECTION
After wave 5, the post-5 leg is scanned for the correction. Wave A is found
first (the first reversal extreme in the first abcAzone% of the post-5 leg),
then C (the correction extreme after A), then B (the bounce strictly between A
and C). If the correction has not developed enough bars, C is not drawn as a
confirmed pivot -- instead a projected target labeled "C?" is shown at the
right edge so you can see where the correction is aiming.
LAYER 4 -- MINOR AND MICRO SUB-WAVES (FRACTAL NESTING)
Once the major pivots exist, the same decomposition is applied inside each leg:
Motive legs (0-1, 2-3, 4-5, motive correction legs) -> minor i-ii-iii-iv-v
Corrective legs (1-2, 3-4, A-B) -> minor a-b-c
Turning on Micro subdivides wave 3's motive sub-legs one degree further into
(i)-(iv). Legs shorter than `minorMinBars` are left unlabeled, because a leg
too short to hold a real sub-pattern should not be cluttered with one.
LAYER 5 -- CONFIDENCE SCORE
The count is graded against seven structural Elliott rules:
1 Wave 1 moves in the trend direction
2 Wave 2 does not pass the origin
3 Wave 2 stays inside wave 1
4 Wave 3 exceeds wave 1
5 Wave 4 stays inside wave 3
6 Wave 4 does not overlap wave 2
7 Wave 5 exceeds wave 4
The confidence % is built from how many of the seven rules hold, with a bonus
when wave 3 is the longest wave. The status label colors the result green
(strong), yellow (plausible), or orange (the window probably does not hold one
clean impulse).
─────────────────────────────────────────────────────────────
WHAT YOU SEE ON THE CHART
─────────────────────────────────────────────────────────────
Major 0-1-2-3-4-5 Aqua bubbles -- the dominant impulse
Major A-B-C Purple bubbles -- the correction after wave 5
"C?" Gray bubble at the right edge -- projected, not yet formed
Minor i-v Gray -- a motive leg subdivided
Minor a-b-c Silver -- a corrective leg subdivided
Micro (i)-(iv) Dark gray -- 3rd-degree detail inside wave 3 (optional)
Status label Top-left -- direction (UP/DN), confidence %, rules met /7,
whether wave 3 is the longest, slope bias, and window size
All label colors are configurable in the indicator's Colors settings group.
─────────────────────────────────────────────────────────────
HOW TO USE -- READING CONFIDENCE AND TUNING
─────────────────────────────────────────────────────────────
The label is only as good as the window it is reading. If the confidence is
low or the count looks wrong, tune it in this order:
1 ADJUST THE WINDOW FIRST.
Change `lookback` so the window frames ONE clean swing. Too large and it
spans several patterns (confidence drops); too small and there is no room
for five waves. Sweep 200 / 350 / 500 / 1000 and keep the best confidence %.
2 IF THE WINDOW ALONE WON'T REACH 100%, ADJUST THE PIVOT (ZONE) LENGTHS.
`w1ZonePct` and `w3ZonePct` move where waves 1 and 3 are searched, and
`abcAzone` moves where wave A is searched. Make small changes and re-check
the confidence % after each one.
3 CONTROL CLUTTER.
`minSep` and `minorMinBars` decide how much sub-structure is drawn. Raise
them to de-clutter; lower them to label shorter legs.
Color guide: green (>=75) trust it, yellow (55-74) plausible, orange (<55)
re-frame the window before reading anything into the count.
─────────────────────────────────────────────────────────────
INPUTS
─────────────────────────────────────────────────────────────
Lookback (window bars) 100 Analysis window in bars -- THE main knob
Wave-1 zone % 35 Wave 1 searched in the first N% of the leg
Wave-3 zone % 70 Wave 3 searched between Wave-1 zone% and this %
Wave-A zone % 40 Wave A searched in the first N% of the post-5 leg
Min bars A/B/C "formed" 4 Min bars between A/B/C to confirm (else "C?")
Min leg bars for minor 4 Min leg length before minor labels are drawn
Detect A-B-C on Detect and label the A-B-C correction
Minor sub-waves on Draw minor sub-waves (i-v / a-b-c)
Micro (3rd degree) off Draw micro detail inside wave 3
Show status label on Show the direction / confidence label
Slope length 13 Length for the status slope-bias readout
PERFORMANCE: a heavy configuration (minor + micro on a large window) makes the
script do more work. If it lags, turn Micro OFF first, then lower `lookback`.
─────────────────────────────────────────────────────────────
IMPORTANT NOTES
─────────────────────────────────────────────────────────────
-- This is the FIRST version. Additional minor cycles and refinements will be
added in future releases.
-- Suggestions are welcome -- comment below with what you would like adjusted
in the next version.
-- The wave-decomposition pathway was verified in Python before being ported
to Pine.
-- This is a labels-only tool. It is NOT an entry or exit signal.
-- Like any "last-N-bars" analysis, the developing right edge can shift as new
bars arrive while the window slides; closed history is stable on reload.
-- This indicator has not been backtested or forward tested as a trading system.
-- This is not financial advice.
-- Trading involves substantial risk of loss.
-- Use for educational and research purposes only.
─────────────────────────────────────────────────────────────
Open-source -- Free for public use
─────────────────────────────────────────────────────────────
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.