OPEN-SOURCE SCRIPT

Lorentzian Classifier AI - Prediction Accuracy [Dots3Red]

1 593
🧭 LORENTZIAN CLASSIFIER AI - PREDICTION ACCURACY TRACKER [Dots3Red]
Lorentzian distance is a way of measuring how similar two market states are that doesn't let a single outlier feature dominate the comparison. This script uses it to find historical moments that genuinely resembled right now, has them vote on direction — and then keeps an honest, running record of whether those votes have actually been right.

WHY THIS MATTERS
Most similarity-based classifiers measure "how alike" two moments are using plain squared differences — the market equivalent of a ruler. The problem: if one feature briefly spikes (a volatility burst, a momentum blow-off), a ruler-based measurement can wrongly flag two genuinely similar moments as very different, just because of that one temporary outlier.

Lorentzian distance compresses that effect. Two market states that matched closely overall still get recognized as similar, even when one feature happened to spike on one of them. The practical result is a comparison method that's less easily fooled by noise.

📊 Accuracy: 58% (n=214)

It's a scoreboard. Out of 214 predictions this classifier has made on this specific chart, 58% turned out correct. It updates continuously as more predictions resolve.

⚙️ HOW IT WORKS
📐 Four features — RSI, CCI, a directional strength measure (from DMI), and a momentum reading (ROC), each normalized to a comparable scale. Every bar's combination of these four values is treated as a "market state."

🔍 Lorentzian comparison — instead of squared Euclidean distance, similarity between the current state and every past state is measured using log-space differences: log(1 + |difference|) per feature, summed. This is the mechanism that reduces the influence of any single feature being temporarily far apart.

🗳️ K-nearest-neighbor vote — the most similar historical states (configurable count) vote on what happened next: did price rise or fall over the following bars? The vote split becomes the current lean, shown as a percentage.

🎯 Rolling, honest grading — every prediction is stored at the exact moment it's made and only graded once its outcome window has fully closed, using the vote as it stood at that time — never recalculated afterward with the benefit of hindsight. This is what makes the accuracy stat trustworthy rather than circular.

🔒 Non-repainting — predictions and their grading both happen strictly on confirmed bars.

🧭 HOW TO USE
1️⃣ Wait for the training sample to build. Early on a fresh chart, the dashboard shows "Training…" instead of a vote — the classifier needs a real base of past states before comparisons mean anything.

2️⃣ Check the Accuracy stat before weighting any single vote. A 65% accuracy over 200+ predictions is meaningfully different from 65% over 15 — the sample size tells you how much to trust the number itself.

3️⃣ Use Min Vote Confidence to filter noise. Labels only appear when the vote split is sufficiently lopsided (60%+ by default) — a near-coin-flip 52% lean isn't flagged, since that's not a meaningful signal either direction.

4️⃣ Treat the vote as a lean, not a forecast. It's an answer to "what happened after similar past moments," not a guarantee about this specific one.

5️⃣ Let the accuracy stat itself guide your confidence in the tool. If it's tracking meaningfully above 50% over a large sample, the method is finding something real on this chart. If it's hovering near 50%, that's honest information too — this particular market state may not carry much predictive signal here.

⏱️ WHICH TIMEFRAMES WORK BEST
This method needs a genuinely large history of past market states to compare against, which makes 15-minute through 4-hour the most effective range.

On very short timeframes (1-3 minute), the training sample grows quickly, but each individual state is closer to noise — indicator readings barely settle before the next bar arrives. On daily or higher timeframes, the states themselves are more meaningful, but building even a modest training sample takes considerably longer in real time. 15-minute to 4-hour balances the two: enough distinct market conditions cycle through regularly to build a genuine sample within a reasonable window, while each state still reflects settled, meaningful market behavior.

🛠️ SETTINGS
📐 Features — independent lengths for RSI, CCI, DMI, and ROC

📊 Lorentzian Engine
• Prediction Horizon — how many bars ahead each prediction looks, and the outcome used to grade it
• K Neighbors — how many similar past states vote on the current one
• Max / Min Training Samples — memory cap and the minimum before votes display
• Min Vote Confidence to Signal — how lopsided the vote must be before a label appears

🎨 Visualization — prediction labels, optional background tint by current lean, independent bullish/bearish colors

🖥️ Dashboard — show/hide, position — current vote split, training sample progress, accuracy with sample size, prediction horizon, and K neighbor count

📝 NOTES
The accuracy stat is specific to this chart, this timeframe, and these settings — it does not transfer to other instruments or configurations. A classifier that performs well on one chart may perform differently on another; the honest way to know is to let it run and check the accuracy stat for the specific setup you're using.

⚠️ DISCLAIMER
This is an analytical and visualization tool. It does not generate trade signals and does not constitute financial advice. Historical prediction accuracy does not guarantee future performance.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.