All indicators

Machine Learning: Lorentzian Classification

Jan 23, 2023

Static chart image
SignalsForecastingMachine 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 indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.