
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.
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