Intercept
The Intercept node computes the OLS y-intercept of the linear regression over the rolling window (x = bar index 0..n−1, y = value). It represents where the best-fit trend line crosses the y-axis at index 0 within the window. Combined with the Slope node, the Intercept allows you to reconstruct the full trend line at any bar within the window, or to project it forward.
Algorithm
- ▸Build pairs (i, v[i]) for non-null v[i] within the window
- ▸OLS: compute x̄, ȳ, then slope β₁ = Σ(x−x̄)(y−ȳ) / Σ(x−x̄)²
- ▸intercept β₀ = ȳ − β₁ × x̄
- ▸Requires ≥ 2 non-null pairs; returns null otherwise
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size. |
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Inputs | ||
| input | number[] | Source numeric array |
| Outputs | ||
| values | number | null | Computed value at each bar; null before the warmup period completes |
| timestamps | number[] | Bar timestamps (UNIX ms), aligned 1-to-1 with values |
Use Cases
Trend Line Reconstruction
Combine Slope and Intercept to reconstruct the fitted trend line value at any bar: fitted[i] = intercept + slope × i (within window).
Trend Projection
Extrapolate the regression beyond the window: project = intercept + slope × (period + n_bars_forward) for short-term price targets.
Baseline Anchoring
The intercept indicates the trend line's starting level — useful for detecting whether the trend is anchored at support or has shifted since the window started.