OPEN-SOURCE SCRIPT

Pattern Analog Projection

447
Pattern Analog Projection

OVERVIEW
This tool searches historical price action for the sequences that most closely
resemble the current market structure, then projects what typically followed
those analogous sequences. It is a context and probability tool, not a buy/sell
signal generator.

HOW IT WORKS
- Shape matching: the last N bars are compared against historical windows using
Pearson correlation, which is invariant to price level and scale. This compares
pattern geometry rather than absolute prices.
- Volatility gating: candidates whose relative-volatility profile differs too much
from the current window are rejected, so analogs share a similar character.
- Top analogs: the best non-overlapping matches are ranked and stored (up to 5).
- Forecast cone: the future paths that followed each analog are aggregated. The
dashed center line is the average projection; the shaded envelope spans the most
bullish and most bearish analog outcomes.
- Probability: the share of analogs that finished bullish, bearish, or neutral
over the projection horizon.
- Confidence: a 0-100 score (graded A+ to C) combining match quality, directional
agreement, and outcome consistency.
- Market regime: the current structure is classified (Strong Trend, Trending,
Range, Compression, Volatile Expansion) using an efficiency ratio and ATR.

INPUTS
- Pattern Length, Projection Length, Search Depth, Search Step
- Number of Analogs, Min Correlation Filter, Forecast Mode (Average / Best / Median)
- Volatility Matching and tolerance, Neutral Band
- Toggles for cone, historical analogs, similarity heatmap, dashboard
- Dashboard position and colors

HOW TO USE
1. Add to any symbol and timeframe; load plenty of history for better matches.
2. Read the Confidence grade first. Treat low-confidence forecasts with caution.
3. Use the cone as a likely-path context, combined with your own trade plan and
risk management - not as a standalone entry trigger.
4. The highlighted region shows the closest historical analog for reference.

NOTES
- The projection re-derives as each new bar closes. It draws forward only and does
not repaint historical bars; there are no historical signals to restate.
- Heavy calculation runs on the last bar. If you see a loop-timeout, lower Search
Depth or raise Search Step.
- Past structural resemblance does not guarantee future outcomes. This script is
for research and education only and is not financial advice.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.