Linear regression R²
How well a straight line fits recent values, from 0 (no fit) to 1 (perfect fit).
R² of the least-squares line through the last length values of the source (current included): the share of the window's variance the line explains, 0–1. A flat window is not ready. Mirror: neutral (a mirrored trend fits its line equally well).
Settings
| Setting | Default | Range | What it does |
|---|---|---|---|
| length | 20 | 2 to 1000 | Values in the window. |
What it gives
| Output | What it is |
|---|---|
| r2 | R², 0–1. |
What it reads
It reads open, high, low, close, hl2, hlc3, ohlc4, hlcc4, close by default.
Warm-up
With its default settings, Linear regression R² needs 20 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.
Test it
Copy this sentence into the Algonney chat to backtest it:
Backtest a strategy on BTC that uses Linear regression R² with its default settings