The short version. "Lorentzian Classification Strategy" by StrategiesForEveryone wraps jdehorty's well-known machine learning indicator in a full strategy: a 200 EMA filter, an ATR stop, break-even at 1R, half off at 3R, and a SuperTrend exit. It has about 5,800 boosts. I ported it to Python and ran it on Exness tick data for seven markets, M15 to D1, January 2020 to September 2026, with real spread and commission.

Before anything else: I sell an MT4/MT5 version of the Lorentzian Classification indicator on this site. So this isn't an independent review, and you should read it knowing that. It doesn't change any number below. They all come from the same backtest code I use for the rest of this series, including the parts that don't flatter the indicator.

  • Your TradingView plan changes the trades. Same script, same US500 H1 chart, same end date. With 5,000 bars loaded it made PF 0.93. With 15,000 bars, 1.36. Only 39% of the trades were the same.
  • The machine learning part didn't add anything I could measure. I slid the kNN prediction to random points in time and kept everything else. On gold H1 the real one beat 70% of the shifted copies, on US500 55%, on USDJPY 33%. Chance alone gets you numbers like that.
  • Where it made money, the trade management did the work. Gold H1: PF 1.18 in R after costs, 577 trades, 23% winners. Longs PF 1.43, shorts 0.90.
  • Forex majors lost. EURUSD, GBPUSD and NZDUSD were below 1 on M15, M30 and H1 after costs.
  • On US500, the market the author showed, it went flat after publication. PF 1.63 in the author's own backtest window, 1.04 over the 333 trades after 14 April 2023.

My take: the strategy shell around the indicator is a decent trend-following frame on gold. Don't credit the "machine learning" for the results, and don't trust a TradingView backtest of it until you know how many bars your chart loaded.

What is the Lorentzian Classification Strategy?

It's an open-source strategy published 14 April 2023. The signal comes from jdehorty's "Machine Learning: Lorentzian Classification" indicator. The author added the trade management.

The signal. On every bar the indicator computes five features: RSI 14, WaveTrend 10/11, CCI 20, ADX 20 and RSI 9, each squeezed into 0–1. It then looks through stored bars for the 8 most similar ones, measuring distance as the sum of log(1 + |difference|) per feature. Each stored bar carries a label: which way price moved over 4 bars. The 8 labels are summed into a prediction from −8 to +8.

A buy fires when the prediction turns positive, a volatility filter and a "regime" filter both pass, and the kernel regression line (the blue line below) is rising. Sells are the mirror image.

The strategy around it. Buy only above the 200 EMA, sell only below. The stop goes 1.5 × ATR(14) from the close. At 1R the stop moves to break-even. At 3R half the position closes. The rest closes on the opposite signal or when price crosses SuperTrend (2.5, 9), but only if the trade is in profit at that moment. Orders fill on the bar close (process_orders_on_close = true). Size is 2.5% of equity at risk.

One Lorentzian Classification Strategy trade on XAUUSD H1, 15 to 17 April 2025: candles, EMA 200, kernel regression line, SuperTrend, buy and sell labels, stop, break-even and 3R take-profit levels, Exness tick data

That's the best case. A buy on 15 April 2025 at 22:00 UTC, stop about 14 USD below. Gold ran through 1R and 3R within a day, half came off at 3R, and the rest rode until the next sell label. Whole trade: +4.45R.

The bug that makes your plan matter

Here's the part almost nobody notices. The kNN loop reads its stored bars starting from index 0, and index 0 is the first bar on your chart. With the default Max Bars Back of 2000, the "training set" is the oldest 2,000 bars TradingView loaded. Predictions only run on the newest 2,000 bars.

How many bars TradingView loads depends on your plan: around 5,000 on the free tier, 10,000 or more on paid plans. So a free user and a paid user looking at the same chart are running two different models, trained on two different stretches of history.

I tested exactly that. US500 H1, chart ending 14 April 2023, the script trading its last 2,000 bars (5 December 2022 to 13 April 2023):

Cumulative R of the Lorentzian Classification Strategy on US500 H1 with 5,000, 10,000 and 15,000-bar charts ending 14 April 2023, plus each chart's entries, Exness tick data, spread included

Chart length Learns from Trades PF (R) Net R
5,000 bars May – Sep 2022 33 0.93 −1.3
10,000 bars Jul – Nov 2021 24 1.38 +4.8
15,000 bars Aug – Dec 2020 35 1.36 +7.4

Same symbol, same dates, same settings. Only the chart length differs.

The 10,000 and 15,000-bar charts shared only 20% of their trades. On gold the three charts gave PF 2.08, 2.20 and 1.64 over the same window. On USDJPY, 0.72, 0.63 and 0.64.

This also answers the repaint question. After a bar closes its signal stays put for that session. But reload the chart a few weeks later and the first bar has moved, so the training set has moved, and old signals can change.

The MT4/MT5 version I sell doesn't do this. It searches the 2,000 bars right before each bar, so the signals don't depend on how much history the terminal loaded. That also means they won't match TradingView bar for bar. It's on the Lorentzian Classification product page.

How I tested it

  • Port: Python with numba. Features and filters follow jdehorty's MLExtensions and KernelFunctions libraries line by line. Trade management follows the strategy script, including fills at the close and stop and limit fills inside the bar.
  • kNN window: four versions. "5,000-bar chart" rebuilds the training set the way a 5,000-bar chart would at every bar. That's my default. "Fixed" uses the first 2,000 bars of the data. "Rolling" uses the latest 2,000 bars, close to how my MT4/MT5 version works. "Expanding" uses all history.
  • Data: Exness Raw Spread ticks for XAUUSD, US500, USDJPY, EURUSD, GBPUSD and NZDUSD, January 2020 to September 2026. BTCUSD from January 2024.
  • Costs: buys fill at the real ask, sells at the bid, plus 3.5 USD per lot per side on forex and gold. No swap.
  • Units: R, the risk at entry. The script sizes every trade to the same risk, so R is what its own report measures. I also report gold in USD per 0.01 lot.
  • Older data: Dukascopy M1 via Tickstory, 2004 to 2026, for gold and four forex pairs.

The results

H1, Jan 2020 – Sep 2026, after costs, 5,000-bar chart:

Market Trades Win rate PF (R) Net R Max DD (R) Long PF Short PF
XAUUSD 577 23% 1.18 +54.9 22.8 1.43 0.90
US500 536 23% 1.20 +51.9 25.4 1.31 1.04
USDJPY 600 22% 1.08 +26.7 17.3 1.15 1.00
BTCUSD* 308 21% 1.09 +15.0 29.2 1.13 1.05
GBPUSD 665 24% 1.01 +4.2 36.3 1.05 0.97
EURUSD 626 20% 0.84 −57.3 80.2 0.78 0.91
NZDUSD 648 21% 0.85 −53.9 72.3 0.83 0.87

*BTCUSD January 2024 – September 2026.

Gold H1 in money: +868 USD per 0.01 lot, while holding gold made +2,588 over the same period. At the script's 2.5% risk per trade, gold H1 grew an account 2.55 times with a 48% drawdown along the way. US500 H1: 2.48 times, 53% drawdown.

All timeframes, using the rolling window so every cell covers the full period:

Lorentzian Classification Strategy profit factor in R after costs by market and timeframe, M15 to D1, XAUUSD US500 USDJPY BTCUSD EURUSD GBPUSD NZDUSD, trade counts in each cell, Exness Raw Spread ticks 2020 to 2026

M15 and M30 lost on every forex pair and on gold. H4 looks better (gold 1.32, USDJPY 1.41), but those cells hold 150–200 trades. The D1 column is 16–31 trades per cell, too few to mean anything.

The four kNN windows barely differed. Gold H1 ranged from 1.17 to 1.21, US500 H1 from 1.20 to 1.32. That's the first hint the kNN isn't what's making money.

Where does the profit come from? On gold H1, trades closed by the opposite signal or SuperTrend averaged +2.6R. Stops averaged −1.0R. Break-even exits came out at about zero. The 3R target was reached on 20% of trades. It's a classic trend system: lose small often, win big rarely.

Does the machine learning help?

I couldn't find any evidence that it does.

Shifted predictions. I took the kNN prediction series and slid it to a random point in time, 100 times, leaving the filters, the kernel, the EMA and the exits exactly as they were. If the kNN knew something about the next few bars, the real series should beat nearly all the shifted ones.

Profit factor of the Lorentzian Classification Strategy with the real kNN prediction versus 100 time-shifted copies, XAUUSD, US500 and USDJPY H1, Exness tick data 2020 to 2026

It beat 70% on gold, 55% on US500 and 33% on USDJPY.

No kNN at all. I replaced the prediction with the direction of the kernel line. US500 H1 made PF 1.26, more than the 1.20 with the kNN. Gold 1.13 versus 1.18, USDJPY 1.08 versus 1.08.

Changing the model. 4 or 16 neighbors instead of 8, Max Bars Back 1,000 or 4,000: PF moved by 0.05 at most.

There's also an oddity in the labels. A bar where price rose over the last 4 bars is stored as a short label. Since RSI and friends are high after a rise, the model's neighbors mostly describe what just happened, not what comes next.

Before and after publication

The author's description shows a backtest on US500 H1 from 19 July 2022 to 14 April 2023. That window happens to be the best stretch in my data:

Cumulative R on US500 H1 from 2021 to 2026, long plus short, long only and short only, with the author's backtest window shaded and the publication date marked, Exness tick data, spread included

PF 1.63 inside the author's window (2.07 with the fixed training set). After publication, PF 1.03 to 1.09 across all four kNN windows, over about 330 trades. Most of the curve since 2023 comes from the long side while the S&P went up.

Is gold an edge or just gold going up?

Gold is the one cell that held up on old data. Dukascopy, 2004 to 2019, spread and commission, no swap:

Gold price on a log scale and cumulative R of the Lorentzian Classification Strategy on gold H1 from 2004 to 2026, long plus short, long only and short only, 2004 to 2019 shaded, Dukascopy M1 data

Profit factor (R) 2004–2011 2012–2019 2020–2026
Gold H1, long + short 1.18 1.17 1.09
Gold H1, short side 0.95 1.18 0.75
Gold H4, long + short 1.55 1.17 1.16
EURUSD H1 1.14 1.10 0.82
GBPUSD / USDJPY / NZDUSD H1 1.03 / 0.85 / 0.98 1.03 / 1.14 / 1.02 0.97 / 1.04 / 0.81

From 2012 to 2019, when gold fell and then drifted, the short side made money. So this isn't only a long bias. It follows whichever trend gold is in. But the shifted-prediction test on 2004–2019 still gave p = 0.10 for gold H1, and I ran it on ten cells, so I can't call that significant either. EURUSD did well before 2020 and lost after. (Gold 2020–2026 shows 1.09 on Dukascopy versus 1.18 on Exness. That's the data source, mostly spread.)

Shifting the H1 candle open by 15, 30 or 45 minutes kept gold between 1.08 and 1.18, US500 between 1.07 and 1.20.

Risk structure

  • Win rate 20–25%. On gold, US500 and USDJPY H1 the longest run without a single winning trade was 18 trades, counting break-even exits. The longest run of full stops was 6–8. At 2.5% risk, that's where the 48–53% drawdowns come from.
  • Stops hold, mostly. Nearly every loss is close to −1R. The exceptions are weekend gaps.
  • The ten worst gold H1 trades, USD per 0.01 lot, after costs (times UTC):
Entry Exit Side Entry price Stop distance Loss R Exit Held
9 Apr 2026 14:00 12 Apr 22:00 Buy 4,768.5 37.8 −98.2 −2.60 Stop, weekend gap 80 h
4 Feb 2026 15:00 4 Feb 23:00 Sell 4,920.6 79.6 −79.7 −1.00 Stop 8 h
12 Feb 2026 16:00 13 Feb 14:00 Sell 4,954.9 55.9 −55.9 −1.00 Stop 22 h
30 Mar 2026 00:00 30 Mar 02:00 Sell 4,432.4 54.9 −55.0 −1.00 Stop 2 h
7 Apr 2026 22:00 8 Apr 14:00 Buy 4,818.4 54.5 −54.6 −1.00 Stop 16 h
17 Jun 2026 19:00 17 Jun 23:00 Sell 4,235.8 39.7 −39.8 −1.00 Stop 4 h
25 Feb 2026 02:00 26 Feb 14:00 Buy 5,180.7 39.6 −39.7 −1.00 Stop 36 h
12 Apr 2026 22:00 13 Apr 00:00 Sell 4,658.9 38.8 −38.9 −1.00 Stop 2 h
31 Dec 2025 05:00 31 Dec 06:00 Sell 4,285.9 37.6 −37.7 −1.00 Stop 1 h
16 Sep 2026 18:00 17 Sep 01:00 Sell 4,261.1 35.7 −35.8 −1.00 Stop 7 h

All ten are from the last year, because the stop is sized by ATR and gold's ATR tripled. In R they're ordinary losses.

  • No martingale, no grid, no averaging. One position at a time.

What are the best settings?

Keep the defaults and pick the market and timeframe instead. Nothing I changed inside the model mattered: neighbors, Max Bars Back, kNN window. The settings that do matter are the trade management ones, and the 200 EMA. H1 and H4 on gold, US500 or USDJPY were positive. M15 and M30 lost almost everywhere after spread.

Who should use it?

If you trade gold or an index on H1–H4 and like the look of the signals, the strategy shell (200 EMA side, 1.5 ATR stop, break-even at 1R, half at 3R, trail the rest) is a reasonable frame, and it held on gold back to 2004. Expect to lose three trades in four.

If you want a model that predicts price, this isn't one. And if you're judging it from the TradingView Strategy Tester, write down how many bars your chart had, because a different plan would have shown you different trades.

What I couldn't verify

  • TradingView's own report. My numbers come from my port. I matched the libraries line by line but couldn't compare trade lists with TradingView's tester.
  • Pepperstone US500. The author tested Pepperstone; I used Exness US500.
  • Swap. Not included. Gold longs held overnight pay it.
  • Live fills. Fills are at the bar close with real spread, not live execution.

Bottom line

The TradingView Lorentzian Classification Strategy made money on gold, US500 and USDJPY H1 from 2020 to 2026 and lost on the forex majors. Its profit came from the trend-following trade management, not from the kNN, which did no better than its own predictions slid in time. On TradingView, the backtest changes with the number of bars your chart loads, because the model learns from the oldest bars on the chart.

If you want the indicator itself on MT4 or MT5, searching recent bars instead of the oldest ones, it's on the Lorentzian Classification product page.

This is part of a series where I port the most-boosted open-source TradingView strategies and test them on broker ticks with real costs. For one that held on 16 years of unseen gold data, see the Super Scalper backtest. For another script whose famous backtest falls apart once you look at the chart settings, see the UT Bot backtest.

I sell an MT4/MT5 port of the Lorentzian Classification indicator. I'm not affiliated with TradingView, jdehorty or StrategiesForEveryone. Past results, including backtests, don't guarantee future results.