OPEN-SOURCE SCRIPT

Elliott Wave Rule Engine

338
What this tool does

The indicator scans price for two concurrent swing structures—a Small (shorter-degree) and a Large (higher-degree) set—then applies an Elliott/NeoWave rule engine to the most recent 5-swing motive (1-2-3-4-5) or 3-swing corrective (A-B-C). It produces:

Blue lines for Small swings and Orange lines for Large swings.

A rule dashboard (optional) showing PASS/FAIL/WARN for core rules & guidelines.

Buy/Sell labels when (a) a valid motive completes and (b) loop “consensus,” alignment, and scoring gates are satisfied.



Reading the chart

Small swings: thin blue segments, built from your Small settings.
Large swings: thicker orange segments, from your Large settings.
Background tint: faint green when a motive (impulse/diagonal) is valid right now on Small.
Labels (if enabled):
“1…5” or “A-B-C” markers on the latest detected structure.
Buy/Sell label at the last pivot when all gates pass; text may include a score %.

How it works
For both Small and Large degrees the script:
- Loops over all (left, right) combinations you specify (e.g., Small Left = 3..6, Right = 0..0) and calls ta.pivothigh/low.
- Aggregates the results:
- Keeps the most extreme pivot found in the loop (highest high or lowest low) that’s newer than the last accepted swing.
- Gates acceptance by minimum % change versus the last opposite swing (inside the loop) and a post-aggregation filter (Small Minimum swing %, Large Minimum swing %).
- Merges back-to-back same-type swings (HH or LL) by keeping only the more extreme one.
- Keeps only the last N=lookbackWaves swings (default 100).
- Consensus (used for signals) comes from the loop counts:
- sBuyConsensus = small L-count / total-combos (bullish bias)
- sSellConsensus = small H-count / total-combos (bearish bias)
(and the same for Large). This is a data-driven “how many combos agreed” measure.

2) Rule engine (Impulse/Diagonal vs. Corrective)

When there are at least 6 Small swings, the engine tests 1-2-3-4-5:

Hard rules (must pass for an Impulse):

- Wave-2 not > 100% of Wave-1 (no retrace beyond start of W1).
- Wave-3 not the shortest among 1,3,5.
- Wave-4 doesn’t overlap Wave-1 (if it does, structure may be a Diagonal).
- Diagonal eligibility: Rules 1 & 2 pass but Rule 3 fails ⇒ eligible as a Diagonal (

Guidelines (7 checks, count toward a threshold you set):

- W2 retraces a Fib level (within ±fibTol).
- W4 retraces a Fib level (within ±fibTol).
- W3 strongest momentum (speed = |Δprice| / bars).
- Alternation: W2 vs W4 have meaningfully different “sharpness” (price per bar), threshold altSlopeThr.
- Proportion (Price): |W1| and |W3| within propTolP× each other.
- Proportion (Time): W1W3 and W2W4 durations within propTolT×.
- W5 weaker than W3 (momentum divergence proxy).

A Motive is valid if:
- Impulse: all 3 hard rules pass and guideline passes ≥ Min guideline passes.
- Diagonal: diagonal-eligible and guideline passes ≥ Min guideline passes.
- if motive fails, the engine still evaluates ABC as Zigzag and Flat to populate the table:
- Zigzag: B shallower than ~0.618A; C ≈ A or 1.618A (±fibTol).
- Flat: B ≥ ~0.9A; expanded flat if B > 1.0A and C in [~1.272..~1.618]*A; “running” note if C < A.

3) Signal logic (consensus-gated & scored)

Signals fire only on new Small pivots and only if a Small motive just validated:Direction comes from the motive’s W1 (up = bull, down = bear).

Consensus checks (from the loop):

Use Sell consensus if the last pivot is a High, or Buy consensus if it’s a Low.Require it ≥ Min SMALL loop consensus and ahead of the opposite side by at least Min consensus margin.If you also require Large quality: check the corresponding Large consensus ≥ Min LARGE loop consensus.

Alignment: If Require small/large directional alignment is ON, Small and Large directions must match (or the Large motive must be complete).

Score:

- If Large not required: finalScore = smallConsensus × smallQuality.
- If Large required: finalScore = smallConsensus × smallQuality × largeQuality.
- Need finalScore ≥ Min final score.

When all gates pass, you’ll see “Buy xx%” or “Sell xx%” at the pivot.

Inputs (explained):
- Smaller Wave Swing Detection (Looped)
- Small Left Min / Max (default 3..6): ta.pivot* left widths to scan.
- Small Right Min / Max (default 0..0): right widths to scan (0 = earliest confirmation).
- Small Minimum swing % (post-aggregation) (0.3%): filters out tiny swings after the loop.
- Larger Wave Swing Detection (Looped)
- Large Left Min / Max (100..200) and Right Min/Max (0..0): higher-degree scan (defaults are big; adjust for intraday).
- Large Minimum swing % (post-aggregation) (1.5%).
- Loop Filters (inside the loop)
- Small loop min % change (0.20%): a candidate pivot counts only if move vs. last opposite Small swing ≥ this.
- Large loop min % change (1.50%): same idea for Large.

Rule Engine Tolerances

- Fibonacci tolerance (±%) (0.05 = 5%): closeness to Fib levels.
-Same-degree TIME proportion max (x) (2.00×) and PRICE proportion max (x) (3.00×).
- Alternation slope ratio threshold (0.10): higher = stricter alternation.
- Min guideline passes (0–7) (5): threshold for motive validity.
- Signal Probability (Loop Consensus)
- Min SMALL loop consensus (0.60).
- Min LARGE loop consensus (0.50) (used only if Large validation matters).
- Min consensus margin vs opposite (0.10): e.g., 0.60 vs 0.45 fails (margin 0.15 passes).

Require LARGE 1–5 valid (or diagonal) for signal (off by default).
Min final score (0.20): gate on the composite score.
Annotate label with score % (on).


WARN (orange): guideline not met—pattern can still be valid if total passes ≥ Min guideline passes.


FAQ

Q: Why did I get a diagonal instead of an impulse?
A: Wave-4 overlapped Wave-1 (Rule 3). If Rules 1 & 2 pass and guidelines meet your minimum, it’s eligible as a Diagonal.

Q: Where do Buy/Sell labels come from?
A: Only after a valid Small motive at a new pivot, and only if consensus, alignment, and final score gates pass (per your settings).

Q: It “missed” a wave in hindsight.
A: Pivots require right bars to confirm; extremely tight settings can filter that swing; adjust Small min % or ranges.

Q: Are there repaints?
A: No, It uses standard pivot confirmation; until a pivot is confirmed, recent swings can evolve. After confirmation, lines/labels are stable.

Limitations & disclaimers

Elliott/NeoWave rules are heuristics; markets are messy. Treat outputs as structured context, not certainty.

Consensus is pattern-scan agreement, not probability of profit Not investment advice; always couple with risk management.


スナップショット

スナップショット

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。