Skip to main content
RSI PCA forecast on a BTC chart

BTC on 1-hour bars in the 0xArchive Terminal, 2026-10-25.

Open on a chart

Load it on BTC 1h in the terminal, then change its settings or open it in the script editor.
RSI at 23 lengths, from 2 to 24, reduced to the 3 ways they move together, and a forecast of the 6-bar return from those 3. The forecast is refit every 100 bars on the 500 bars before, and frozen in between: a walk-forward test, a port of neurotrader888’s RSI-PCA. The histogram is the forecast in basis points, the dashed lines the long and short thresholds, the shade the position, and a diamond under the candles marks each refit.

How it works

lengths.map((n) => ta.rsi(n)) builds the 23 indicators. ml.forward hands each bar’s RSIs to ml.pcr only once the 6-bar return after them is known. Every 100 bars ml.pcr finds the principal components of the last 500 labelled bars, fits the return on the first 3, and freezes the components and the coefficients together, so the model never applies old coefficients to new components. A forecast above the 99th percentile of the fit’s own in-sample forecasts is a long signal, below the 1st a short one. ta.sma over 6 bars holds each signal for the horizon, as the original does, so the position runs from −1 to 1. The original trains on 2 years of hourly bars and refits yearly. The chart loads far fewer bars, so the defaults are 500 and 100; both are inputs. The original also projects on rows of the eigenvector matrix, which are not principal components; this uses the columns.

The script

rsi-pca-forecast.ts

Next step

See the next example, RSI cross, pasted Pine.
Last modified on October 25, 2026