Skip to content

Oscillators & Volume

Exact formulas, smoothing rules, and defaults for VOL, RSI, MACD, ATR, ADX, STOCHRSI, and OBV.

Sub-pane indicators render below the main price pane, sharing the same O(1) incremental checkpointing and TA-Lib seeding as overlays.

VOL (Volume)

  • Defaults: calcParams: [5, 10, 20] (Neumaier-compensated SMA lines plotted over volume bars).
  • Coloring: Bars color bullish (upColor) when close > open, bearish (downColor) when close < open, and neutral (noChangeColor) on flat closes. Axis floors at minValue: 0 with abbreviated big-number formatting.

RSI (Relative Strength Index)

  • Defaults: calcParams: [6, 12, 24] (three simultaneous RSI lines; note that the divergence study uses single rsiPeriod = 14).
  • Formula: Wilder’s smoothing (matching TA-Lib RSI).
    • Seeds gain and loss as the mean of positive/negative bar-to-bar close changes over 1..period.
    • Subsequent bars update gain = (gain * (period - 1) + up) / period and loss = (loss * (period - 1) + dn) / period.
    • RSI = 100 * (gain / (gain + loss)) (returns 0 when |gain + loss| < 1e-14).

MACD (Moving Average Convergence Divergence)

  • Defaults: calcParams: [12, 26, 9] (fast = 12, slow = 26, signal = 9).
  • Outputs: DIF (MACD line), DEA (signal line), and MACD histogram bars (DIF - DEA; hollow stroke when rising bar-over-bar, solid fill when falling).
  • TA-Lib seeding nuance: Both fast and slow EMAs seed at the same index slow - 1 (each taking the SMA of its own length ending at slow - 1). Signal EMA seeds signal - 1 bars later, so DIF, DEA, and histogram begin together at bar slow + signal - 2 (33 for 12/26/9), matching TA-Lib exactly.

ATR (Average True Range)

  • Defaults: calcParams: [14], minValue: 0.
  • Formula: True Range TR[i] = max(h[i] - l[i], |h[i] - c[i - 1]|, |l[i] - c[i - 1]|). Seeds at bar period with mean(TR[1..period]), then applies Wilder’s smoothing atr = (prev * (period - 1) + TR) / period.

ADX (Average Directional Index)

  • Defaults: calcParams: [14], bounded [0, 100].
  • Outputs: ADX (bright), +DI (green), -DI (red).
  • Formula: Standard Wilder directional movement (+DM, -DM, TR smoothed by sm = sm - sm / period + val starting from the period-bar sum at bar period):
    • +DI = 100 * (smPdm / smTr), -DI = 100 * (smMdm / smTr).
    • DX = 100 * |+DI - -DI| / (+DI + -DI).
    • ADX seeds at bar 2 * period - 1 (27 for period 14) with the period-bar mean of DX, then applies Wilder’s RMA.

STOCHRSI (Stochastic RSI)

  • Defaults: calcParams: [14, 14, 3, 3] (rsiPeriod = 14, stochPeriod = 14, kSmooth = 3, dSmooth = 3), short label SRSI, bounded [0, 100].
  • Outputs: %K (accent) and %D (warn).
  • Formula:
    1. Computes Wilder RSI(rsiPeriod).
    2. Over each rolling stochPeriod window of RSI (first = rsiPeriod + stochPeriod - 1), computes raw = 100 * (rsi[i] - minRsi) / (maxRsi - minRsi) (0 if maxRsi - minRsi <= 1e-14).
    3. %K = SMA(raw, kSmooth) and %D = SMA(%K, dSmooth) using Neumaier-compensated rolling sums.

OBV (On-Balance Volume)

  • Defaults: calcParams: [20] (sigPeriod = 20 SMA signal line).
  • Outputs: OBV (accent solid) and MA (dim dashed 20-bar SMA of OBV), formatted with big-number abbreviations.
  • Formula: Starts at v[0], adding +v[i] when c[i] > c[i - 1], -v[i] when c[i] < c[i - 1], and 0 on unchanged closes via Neumaier-compensated summation so multi-month streams remain drift-free.

Type to search…

↑↓ navigate↵ selectEsc close