Machine Learning: Lorentzian Classification

Published on MillionChart by CapitalEdge.

This indicator classifies price bars with a machine-learning method called Lorentzian classification. It looks back through history, finds the bars that resemble the current one across several technical features, and uses their outcomes to estimate where price is likely to move next. The similarity search is an approximate nearest-neighbours approach that uses Lorentzian distance instead of the usual Euclidean distance.

Why Lorentzian distance:
- Market data gets warped by big events such as central bank meetings, so the author treats "price-time" as a space that bends around them.
- Lorentzian distance is less sensitive to outliers and noise, and it lets the model consider historical points that Euclidean distance would skip.
- Implementation details are documented in the source code comments.

General settings:
- Source (default hlc3), Neighbors Count (8, range 1-100), Max Bars Back (2000), Feature Count (5, range 2-5), Color Compression (1-10).
- Show Exits and Use Dynamic Exits (both off by default); dynamic exits use kernel regression to let a move run.

Features:
- Choose each feature from RSI, WT, CCI or ADX, each with two parameters. Defaults are tuned for roughly the 4H to 12H timeframes.

Filters:
- Volatility filter and regime filter (both on), ADX filter (off). Regime Threshold defaults to -0.1 and ADX Threshold to 20.

Kernel regression:
- Trade with Kernel and Show Kernel Estimate (on), Lookback Window 8, Relative Weighting 8, Start Regression at Bar 25.

Display and backtest:
- Bar colors, per-bar prediction values, optional ATR offset, prediction offset, and a win-rate readout for the current configuration.

The author credits several community members for testing, ideas and open-source KNN work.