EWCoreLibEWCoreLib — Elliott Wave Pattern Evaluation Library
Overview
EWCoreLib is a Pine Script v6 library of exported functions that validate and score Elliott Wave price patterns. It has no chart output of its own and is not meant to be added to a chart; a calling script supplies the pivot data and decides what to do with the results.
It is one of three scripts published together: the EWCore indicator, this library, and EWCore Docs, an on-chart reference panel for EWCore.
If you are using EWCore, there is nothing to do here. EWCore pulls in this library itself, as part of its own code — you add EWCore to your chart and the library comes with it. This page exists for Pine programmers who want to call these functions from a script of their own, and as the open source behind EWCore's evaluation stage. The dependency runs one way only: EWCore needs this library, the library needs nothing from EWCore, and any script that can produce its own pivot series can use it.
Relation to the earlier publication
An earlier version of this library was published under the name EWCoreEvaluators. This publication continues the same codebase under a new name; it is not a variant or a competing implementation. The name changed because the earlier title stays bound to the earlier publication and cannot be reused. Any script that imports the old path should be pointed at Wick-Sniper/EWCoreLib, which is the one that receives further work.
Concepts
Pivots in, verdicts out. Every evaluator takes a pivot series — prices and bar positions in two parallel arrays — plus a starting index, and asks one question about the window beginning there: does this stretch of price form the pattern I check for? The answer comes back as a filled WaveCount object carrying the wave points, the hard-rule verdict, the component scores and an invalidation level, or as an empty one if the window does not qualify.
Configuration travels as an object, not as a parameter list. An exported function cannot read the global variables of the script importing it, and these evaluators need a great many settings — tolerances, score weights, Fibonacci levels, feature toggles. Passing them individually would mean unwieldy signatures that break on every added option. Instead the calling script builds one EngineConfig object per bar and hands it to whichever functions it calls.
Every exported function is pure. Parameters in, values out, no hidden state. That is what makes it safe to call the same evaluator from several contexts in one bar — a forward search, a historical chain walk, a sub-wave decomposition — without behaviour drifting between them.
Marginal violations are penalised, not rejected. A candidate that misses a rule by a hair is scored down rather than discarded, so a near-miss reading stays visible and comparable instead of vanishing silently.
Exported types
WaveCount — one complete candidate scenario: pattern type, direction, degree label, wave points and their bars, hard-rule and overlap flags, component scores, confidence tier, invalidation level, extension info.
EngineConfig — the settings bundle described above.
Exported functions, by purpose
Pattern evaluation — one per pattern in the canon this project supports: evaluateImpulseWindow, evaluateDiagonalWindow, evaluateZigzagFlatWindow, evaluateTriangleWindow, evaluateComboWXYWindow, evaluateComboWXYXZWindow, evaluateImpulseRecoveredWindow (rebuilds an impulse whose fourth wave the coarse pivot pass swallowed), evaluateLegWhole (judges a whole leg as a single structure rather than a chain of fragments).
Type arbitration — f_discriminateWindow, f_evalWindowTrio: when impulse, diagonal and triangle all pass on the same window, these decide which type the window really is, so the least strict pattern cannot win by default.
Re-checking and scoring — revalidateCandidate, f_comboBonus, f_dpEdgeModifier, f_legDominance, f_legWholeDominance, f_evalCandDegStep, f_evalFloorLeg, f_candDegPasses, f_floorLegPasses.
Chain and gap handling — f_realGapFill (dynamic-programming best-path search for a continuous chain of valid patterns across a pivot series), f_gapNoiseMetrics, f_depth2InnerLegs.
Degree handling — getDegreeLabel, shiftDegreeUp, shiftDegreeDown, f_degreeNameFor, f_notatedLabelTextArray: translate between Elliott degrees and the notation that belongs to each.
Explanatory text — f_patternExplanation, f_extGlyph, f_extTooltip, f_atomicDiagText, f_gapBridgeText, f_rankStage, f_rankWhy, impulseFunnelText, comboFunnelText: turn a verdict into readable reasoning for labels and tooltips.
Drawing helpers — drawImpulseFunnel, drawComboFunnel, f_drawWholeLegFallback, f_drawWholeLegFallbackFromPivots, f_drawWholeLegFallbackFromArrays, f_drawExplanationLabel, f_drawDateMarker, f_drawRoutedLeg.
Utilities — subLowerBound, f_barValToTime (resolves a stored bar value to a timestamp; historical drawings need xloc.bar_time), getLabelSize, f_lineStyle, f_frameCount.
Calling it from your own script
This section is for Pine programmers writing their own script. EWCore users can skip it — EWCore handles the import itself.
import Wick-Sniper/EWCoreLib/1 as ewcore
Type the alias by hand. The "copy to clipboard" button on the library page appends the library name a second time and produces an import line that does not resolve.
From there, build an EngineConfig once per bar, then call the evaluator for the pattern and window you are testing and read the returned WaveCount.
Notes
This library validates structure; it does not detect pivots. The quality of everything it returns depends on the pivot series you feed it — a threshold that admits noise produces confident verdicts about noise. In this project's own testing, wave counting becomes reliable at 15-minute charts and above.
A passing verdict means a reading exists that satisfies the rules checked, not that it is the correct count. Elliott Wave analysis admits more than one valid interpretation of the same chart, and these functions score candidates rather than settle them.
This library is a technical analysis building block. It is not financial advice and generates no trading signals.
Library

