INVITE-ONLY SCRIPT

ML: Lorentzian Classification Premium

2 965
█ OVERVIEW

Lorentzian Classification Premium represents the culmination of two years of collaborative development with over 1,000 beta testers from the TradingView community. Building upon the foundation of the open-source version, this premium edition introduces powerful enhancements that transform how machine-learning classification can be applied to market analysis.

The premium version maintains the core Lorentzian distance-based classification algorithm while expanding its capabilities through triple the feature dimensionality (up to 15 features), sophisticated mean-reversion detection, first-pullback identification, and a comprehensive signal taxonomy that goes far beyond simple buy/sell signals. Whether you're building automated trading systems, conducting deep market research, or integrating proprietary indicators into ML workflows, this tool provides the advanced edge needed for professional-grade analysis.

█ BACKGROUND

Lorentzian Classification analyzes market structures, especially those exhibiting non-linear distortions under stress, by employing advanced distance metrics like the Lorentzian metric, prominent in fields such as relativity theory. Where traditional indicators assume flat space, we embrace the curve. The heart of this approach is the Lorentzian distance metric—a sophisticated mathematical tool. This framework adeptly navigates the complex curves and distortions of market space, aiming to provide insights that traditional analysis might miss, especially during moments of extreme volatility. It analyzes historical data from a multi-dimensional feature space consisting of various technical indicators of your choosing. Where traditional approaches fail, Lorentzian space reveals the true geometry of market dynamics.

syot kilat
Neighborhoods in Different Geometries: In the above figure, the Lorentzian metric creates distinctive cross-patterns aligned with feature axes (RSI, CCI, ADX), capturing both local similarity and dimensional extremes. This unique geometry allows the algorithm to recognize similar market conditions that Euclidean spheres and Manhattan diamonds would miss entirely. In LC Premium, users can have up to 15 features -- you are not limited to 3-dimensions.

Among the thousands of distance metrics discovered by mathematicians, each perceives data through its own geometric lens. The Lorentzian metric stands apart with its unique ability to capture market behavior during volatile events.

█ COMMUNITY-DRIVEN EVOLUTION

It has been profoundly humbling over the past 2 years to witness this indicator's evolution through the collaborative efforts of our incredible community. This journey has been shaped by thousands of user suggestions and validated through real-world application.

A particularly amazing milestone was the development of a complete community-driven Python port, which meticulously matched even the most minute PineScript quirks. Building on this solid foundation, a new command-line interface (CLI) has opened up exciting possibilities for chart-specific parameter optimization:
syot kilat
Early insights from parameter optimization research: Through grid-search testing across thousands of parameter combinations, the analysis identifies which parameters have the biggest effects on performance and maps regions of stability across different market regimes. This reveals that optimal neighbor counts vary significantly based on market conditions—opening up incredible potential for timeframe-specific optimization.

This is just one of the insights gleaned so far from this ongoing investigation. The potential for chart-specific optimization for any given timeframe could transform how traders approach parameter selection.

Demand from power users for extra capabilities—while keeping the open-source version simple—sparked this Premium release. The open-source branch remains maintained, but the premium tier adds unique features for those who need an analytical edge and to leverage their own custom indicators as feature series for the algorithm.

█ KEY PREMIUM FEATURES


📈 First Pullback Detection System
  • Automatically identifies high-probability trend-continuation entries after initial momentum moves.
  • Detects when price retraces to optimal entry zones following breakouts or trend initiations.
  • Green/red triangle signals often fire before main classification arrows.
  • Dedicated alerts for both bullish and bearish pullback opportunities.
  • Based on veryfid's extensive research into pullback mechanics and market structure.


🔄 Dynamic Kernel Regression Envelope
  • Powerful, zero-setup confluence layer that immediately communicates trend shifts.
  • Dual-kernel system creates a visual envelope between trend estimates.
  • Color gradient dynamically represents prediction strength and market conviction.
  • Crossovers provide additional confirmation without cluttering your chart.
  • Professional visualization that rivals institutional-grade analysis tools.


✨ Massively Expanded Dimensionality: 10 Custom Sources, 5 Built-In Sources
  • Transform the indicator from 5 built-in standard to 15 total total features—triple the analytical power.
  • Integrate ANY TradingView indicator as a machine learning feature.
  • Built-in normalization ensures all indicators contribute equally regardless of scale.
  • Create theme-based systems: pure volume analysis, multi-timeframe momentum, or hybrid approaches.


syot kilat

📊 Tiered Mean Reversion Signals with Scalping Alerts
  • Regular (🔄) and Strong (⬇️/⬆️) mean reversion signals based on statistical extremes.
  • Opportunities often arise before candle close—perfect for scalping entries.
  • Visual markers appear at high-probability reversal zones.
  • Four specialized alert types: upward/downward for both regular and strong reversals.
  • Pre-optimized probability thresholds, no fine-tuning required.


📅 Daily Kernel Trend Filter
  • Instantly cleans up noisy intraday charts by aligning with higher timeframe trends.
  • Swing traders report immediate signal quality improvement.
  • Automatically deactivates on daily+ timeframes (intelligent context awareness).
  • Reduces counter-trend signals by up to 60% on lower timeframes.
  • Simple toggle—no complex multi-timeframe setup required.


📋 Professional Backtesting Stream (-6 to +6)
  • Multiple distinct signal types (including pullbacks, mean reversions, and kernel deviations) vs. basic binary (buy/sell) output for nuanced analysis.
  • Enables detailed walk-forward analysis and ML model training.
  • Compatible with external backtesting frameworks via numeric stream.
  • Rare precision for TradingView indicators—usually only found in institutional tools.
  • Perfect for quants building sophisticated strategy layers.


⚡ Performance Optimizations
  • Faster distance calculations through algorithmic improvements.
  • Reduced indicator load time (measured via Pine Profiler).
  • Handles 15 active features without timeouts—critical for multi-chart setups.
  • Optimized for live auto-trading bots requiring minimal latency.


🎨 Full Visual Customization & Accessibility
  • Complete color control for all visual elements.
  • Colorblind-safe default palette with customization options.
  • Dark mode optimization for extended trading sessions.
  • Professional appearance matching your trading workspace.
  • Accessibility features meeting modern UI standards.


🛠️ Advanced Training Modes
  • Downsampling mode for training on diverse market conditions; Down-sampling and remote-fractals for exotic pattern discovery.
  • Remote fractals option extends analysis to deep historical patterns.
  • Reset factor control for fine-tuning neighbor diversity; Reset-factor tuning to control neighbor diversity.
  • Appeals to systematic traders exploring exotic data approaches.
  • Prevents temporal clustering bias in model training.


█ HOW TO USE

Understanding the Approach (Core Concept):
Lorentzian Classification uses a k-Nearest Neighbors (k-NN) algorithm. It searches for historical price action "neighborhoods" similar to the current market state. Instead of a simple straight-line (Euclidean) distance, it primarily uses a Lorentzian distance metric, which can account for market "warping" or distortions often seen during high volatility or significant events. Each historical neighbor "votes" on what happened next in its context, and these votes aggregate into a classification score for the current bar.

Interpreting Bar Scores & Signals (Interpreting the Chart):
  • Bar Prediction Values: Numbers over each candle (e.g., ranging from -8 to +8 if Neighbors Count is 8) represent the aggregated vote from the nearest neighbors. Strong positive scores (e.g., +7, +8) indicate a strong bullish consensus among historical analogs. Strong negative scores (e.g., -7, -8) indicate a strong bearish consensus. Scores near zero suggest neutrality or conflicting signals from neighbors. The intensity of bar colors (if Use Confidence Gradient is on) often reflects these scores.
  • Main Arrows (Main Buy/Sell Labels): Large ▲/▼ labels are the primary entry signals generated when the overall classification (after filters) is bullish or bearish.
  • Pullback Triangles: Small green/red ▲/▼ identify potential trend continuation entries. These signals often appear after an initial price move and a subsequent minor retracement, suggesting the trend might resume. This is based on recognizing patterns where a brief counter-movement is followed by a continued advance in the initial trend direction.
  • Mean-Reversion Symbols: 🔄 (Regular Reversion) appears when price has crossed the average band of the Dynamic Kernel Regression Envelope. ⬇️/⬆️ (Strong Reversion) means price has crossed the far band of the envelope, indicating a more extreme deviation and potentially a stronger reversion opportunity.
  • Custom Mean Reversion Deviation Markers (Deviation Dots): If Enable Custom Mean Reversion Alerts is on, these dots appear when price deviates from the main kernel regression line by a user-defined ATR multiple, signaling a custom-defined reversion opportunity.
  • Kernel Regression Lines & Envelope: The Main Kernel Estimate (thicker line) is an adaptive moving average that smooths price and helps identify trend direction. Its color indicates the current trend bias. The Envelope (outer bands and a midline) creates a channel around price, and its interaction with price generates mean reversion signals.


Key Input Groups & Their Purpose:
  • 🔧 GENERAL SETTINGS: Reduce Price-Time Warping: Toggles the distance metric. When enabled, it reduces the characteristic "warping" effect of the default Lorentzian metric, making the distance calculation more Euclidean in nature. This may be suited for periods exhibiting less pronounced price-time distortions.
    Source: Price data for calculations (default: close).
    Neighbors Count: The 'k' in k-NN – number of historical analogs considered.
    Max Bars Back: How far back the indicator looks for historical patterns.
    Show Exits / Use Dynamic Exits: Controls visibility and logic for exit signals.
    Include Full History (Use Remote Fractals): Allows model to pick "exotic" fractals from deep chart history.
    Use Downsampling / Reset Factor: Advanced training parameters affecting neighbor selection.
    Show Trade Stats / Use Worst Case Estimates: Displays a real-time performance table (for calibration only).
  • 🎛️ DEFINE CUSTOM SOURCES (OPTIONAL):
    Integrate up to 10 external data series (e.g., from other indicators) as features. Each can be optionally normalized. Load the external indicator on your chart first for it to appear in the dropdown.
  • 🧠 FEATURE ENGINEERING:
    Configure up to 15 features for the k-NN algorithm. Select type (RSI, WT, CCI, ADX, Custom Sources), parameters, and enable/disable. Start simple (3-5 features) and add complexity gradually. Normalize features with vastly different scales.
  • 🖥️ DISPLAY SETTINGS:
    Controls visibility of chart elements: bar colors, prediction values/labels, envelope, etc.
    Align Signal with Current Bar: If true, pullback signals appear on the current bar (calculated on closed data). If false (default), they appear on the next bar.
    Use ATR Offset: Positions bar prediction values using ATR for visibility.
  • 🧮 FILTERS SETTINGS:
    Refine raw classification signals: Volatility, Regime, ADX, EMA/SMA, and Daily Kernel filters.
  • 🌀 KERNEL SETTINGS (Main Kernel):
    Adjust parameters for the primary Nadaraya-Watson Kernel Regression line. Lookback Window, Relative Weighting, Regression Level, Lag control sensitivity and smoothness.
  • ✉️ ENVELOPE SETTINGS (for Mean Reversion):
    Configure the dynamic Kernel Regression Envelope. ATR Length, Near/Far ATR Factor define band width.
  • 🎨 COLOR SETTINGS (Colors):
    Customize colors for all visual elements; override every palette element.


General Approach to Using the Indicator (Suggested Workflow):
  1. Load defaults and observe behavior: Familiarize yourself with the indicator's behavior.
  2. Feature Engineering: Experiment with features, considering momentum, trend, and volatility. Add/replace features gradually.
  3. Apply Filters: Refine signals according to your trading style.
  4. Contextualize: Use kernels and envelope to understand broader trend and potential overbought/oversold areas.
  5. Observe Signals: Pay attention to the interplay of main signals, pullbacks, and mean reversions. Watch interplay of main, pullback & mean-reversion signals.
  6. Calibrate (Not Backtest): Use the "Trade Stats" table for real-time feedback on current settings. This is for calibration, *not a substitute for rigorous backtesting.*
  7. Iterate & refine: Adjust settings, observe outcomes, and refine your approach.


█ ACKNOWLEDGMENTS
This premium version wouldn't exist without the invaluable contributions of:
  • veryfid for his groundbreaking ideas on unifying pullback detection with Lorentzian Classification, but most of all for always believing in and encouraging me and so many others. For being a mentor and, most importantly, a friend. We all miss you.
  • RikkiTavi for his help in creating the settings optimization framework and for other invaluable theoretical discussions.
  • The 1,000+ beta testers worldwide who provided continuous feedback over two years.
  • The Python porting team who created the foundation for advanced optimization; for the cross-language clone.
  • The broader TradingView community for making this one of the platform's most popular indicators.


█ FUTURE DEVELOPMENT
The Premium version will continue to evolve based on community feedback. Planned enhancements include:
  • Specialized exit model trained independently from entry signals (ML-based exit model).
  • Feature hub with pre-normalized, commonly requested indicators (Pre-normalized feature hub).
  • Better risk-management options (Enhanced risk-management options).
  • Fully automated settings optimization (Auto-settings optimization tool).

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.