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 and the dashed lines the long and short thresholds; a diamond under the candles marks each refit, the arrows mark the strategy’s fills, and the equity curve sits in a pane of its own beside buy-and-hold.

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. strategy.target trades it from the next bar’s open, paying the venue’s fee, what the order book charged for the order’s size, and funding while it holds. Open the Strategy report from the legend to see what it made, what each cost took, and how well the forecast scored (ml.score). The original trains on 2 years of hourly bars and refits yearly. The strategy loads history back to 2026-03-10, 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, Residual momentum.
Last modified on October 28, 2026