Machine Learning: Lorentzian Classification

Jan 23, 2023

Static chart image
Signals
Forecasting
Machine Learning

The Machine Learning: Lorentzian Classification indicator is a powerful multi-dimensional feature space tool that uses a Lorentzian Distance metric to predict future price movements based on historical data patterns. By employing a novel implementation of an Approximate Nearest Neighbors (ANN) algorithm, it provides traders with high-probability direction estimates that are more robust to market noise and outliers than traditional Euclidean-based models.

Usage

The Usage section describes how the script can be used to identify potential market reversals and trend continuations. The indicator processes multiple technical features (like RSI, WT, CCI, and ADX) to find similar historical "neighborhoods" in a Lorentzian space.

  • Signal Interpretation: The indicator outputs integer values on the chart representing the model's evaluation. Positive values suggest bullish sentiment, while negative values suggest bearish sentiment. The intensity of the bar colors reflects the strength of the prediction.
  • Kernel Regression: Traders can use the integrated Kernel Regression filter to smooth out noise. When "Trade with Kernel" is enabled, signals are only generated when the ML prediction aligns with the kernel's estimated trend direction.
  • Filter Integration: The tool includes Volatility, Regime, and ADX filters. These should be used to restrict signals during choppy or low-volatility environments, ensuring that the model only predicts during clear market conditions.
  • Dynamic Exits: By enabling dynamic exits, the script uses kernel regression logic to let profits ride, moving the exit threshold based on real-time price action rather than a fixed bar count.

Details

The core concept behind this script is the transition from Euclidean distance to Lorentzian distance. In financial markets, "price-time" is often warped by major news events (like FOMC meetings or black swans). Traditional Euclidean metrics often fail to recognize similar historical patterns if they are "distanced" by high volatility.

Lorentzian distance accommodates this warping by compressing the feature space, allowing the model to identify relevant historical neighbors that would otherwise be ignored. This implementation uses a modified ANN algorithm to ensure computational efficiency within the charting platform while maintaining a high degree of predictive accuracy.

Settings

General Settings

  • Source: The input data source for calculations (default is HLC3).
  • Neighbors Count: The number of historical similar points to consider (1-100).
  • Max Bars Back: Limits the historical lookback for the ML model to optimize performance.
  • Feature Count: Determines how many technical features (2-5) are used for classification.
  • Color Compression: Adjusts the visual intensity of the bar coloring.
  • Show/Use Dynamic Exits: Toggles between fixed-bar exits and regression-based trend following exits.

Feature Engineering

  • Feature 1-5: Selection of technical indicators (RSI, WT, CCI, ADX) used as dimensions in the ML space.
  • Parameter A/B: Customizable periods and smoothing factors for each selected feature.

Filters

  • Volatility/Regime/ADX Filters: Toggleable filters to prevent signals in unfavorable market states.
  • Thresholds: Adjustable sensitivity levels for the trend and volatility detection logic.

Kernel Settings

  • Trade with Kernel: Filters ML signals through the Rational Quadratic Kernel estimate.
  • Lookback Window: The number of bars used for the kernel estimation.
  • Relative Weighting: Controls the influence of different time frames on the kernel curve.
  • Regression Level: Controls how tightly the kernel fit follows the price action.

Display & Backtesting

  • Show Bar Colors/Predictions: Toggles the visual ML output on the price bars.
  • Show Backtest Results: Displays a table with win rates and performance metrics based on the current configuration.

FAQ

How do I interpret the numbers shown above the bars? The numbers represent the model's confidence and direction; positive integers indicate a bullish neighborhood of historical data, while negative integers indicate a bearish neighborhood.

Why are some signals filtered out? Signals are often filtered by the Volatility, Regime, or Kernel filters to ensure that entries only occur when the ML prediction is supported by the broader market trend and sufficient momentum.

How can I access the Machine Learning: Lorentzian Classification indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free access on the following platforms
tradingviewSymbolTradingView
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

ninjatraderNinjaTrader
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

metatrader4MetaTrader 4/5
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

thinkorswimThinkorswim
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.

Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2026 LuxAlgo Global, LLC.