Intercept

Windowed · default period 20Statistics

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

NameTypeDefaultDescription
periodnumber20Rolling window size.

Inputs & Outputs

PortTypeDescription
Inputs
inputnumber[]Source numeric array
Outputs
valuesnumber | nullComputed value at each bar; null before the warmup period completes
timestampsnumber[]Bar timestamps (UNIX ms), aligned 1-to-1 with values
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.

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.