@pond-ts/financial API Reference
    Preparing search index...

    Function pivotPoints

    • Pivot Points — each session's support/resistance ladder, computed from the previous session's high, low and close and held flat across every bar of the current session.

      Appends ${prefix}Pivot, ${prefix}R1..R3 and ${prefix}S1..S3 (plus ${prefix}R4 / ${prefix}S4 for 'camarilla'). The levels are constant within a session — that is the point of them: a floor trader writes the numbers down before the open and trades against them all day.

      const cal = TradingCalendar.fromRules(
      { timeZone: 'America/New_York', open: '09:30', close: '16:00' },
      { from: '2024-01-02', to: '2024-12-31' },
      );
      pivotPoints(bars, { sessions: cal }); // standard
      pivotPoints(bars, { sessions: cal, method: 'camarilla' }); // +R4/S4
      pivotPoints(cal.tagSessions(bars), { session: 'session' }); // column door

      This is the study the corpus assessment (§6.9) gates on G4: the arithmetic was never the hard part — "prior-period H/L/C via aggregate + hold-broadcast is easy" — the anchor rule was, and the trading calendar is what supplies it. Where sessions come from is SessionAnchorOptions: a calendar (the primary door) or a session-id column on an already-partitioned series.

      All four sets read the same three inputs and produce the same shape — a central pivot with a ladder of support and resistance either side — and differ in constants. That is the test keltner's maType had to pass and keltner's hypothetical "band source" flag failed: a flag that swaps which indicator you are computing is two studies wearing one name, and this is not that. Each set is written out in pivotLevelValues; briefly:

      • 'standard' — the floor-trader/classic set, P = (H+L+C)/3 with R1 = 2P − L, R2 = P + (H−L), R3 = H + 2(P−L) and the mirrored supports. The unqualified "pivot points" of every vendor.
      • 'fibonacci' — the same centre with the range scaled by 38.2 % / 61.8 % / 100 %.
      • 'woodie' — the standard ladder over the close-weighted centre P = (H + L + 2C)/4.
      • 'camarilla' (Nick Scott, 1989) — four pairs at 1.1/12, 1.1/6, 1.1/4, 1.1/2 of the range.

      Two deliberate deltas worth naming, since both appear in the wild:

      • Camarilla measures from the CLOSE, not from the pivot. Its levels are C ± k·(H−L), so P rides along as the centre line but no level is computed from it. That is the definition; a build that centred them on P would be a different indicator, and the fixture separates the two.
      • Woodie's is the (H + L + 2C)/4 form, weighting the previous close. A second convention in circulation weights the current session's open instead ((H + L + 2·Open)/4). We ship the previous-close form: it needs nothing but the previous session's aggregate, matching every other method here, and the open form would make one menu entry read a column the other three don't.

      Camarilla defines a fourth pair; the other three do not. The alternative was a fixed nine columns with R4/S4 permanently undefined for three of the four methods, which is worse in every direction: it invents columns that have no definition, makes "missing" ambiguous between not in this method and no previous session, and would have every consumer of a standard-pivot chart carrying two dead series. The return type follows the option — PivotPointsResult is conditional on method — so .get('ppR4') type-checks only where it exists.

      • Every bar of the first session that has bars reads undefined — there is no previous session to measure. Not an error, and not a hole to fill.
      • Every bar in closed time reads undefined, for the same reason sessionVwap does: a bar in no session has no session's levels.
      • "Previous session" means the previous session with bars in this series, not the previous entry on the calendar. A day the feed skipped has no aggregate, and reading the calendar for one would invent a bar.
      • The columns share one warm-up rather than one each: every level of every method reads all three aggregates, so a missing input blanks the whole ladder together.

      previousSessionHlcValues (the aggregate + hold-broadcast, one pass) and pivotLevelValues (the four formula sets). The aggregates are taken over the cells that are present — a bar with a missing high still contributes its low — because max/min/last are three independent order statistics, not the two halves of one ratio; see the kernel for why that differs from the VWAP rule.

      Every level is an affine combination of H, L and C whose coefficients sum to 1, so the whole ladder is equivariant under both: scaling every price scales the levels, adding a constant to every price adds it to the levels. Both are pinned as property tests.

      Type Parameters

      • S extends SeriesSchema
      • const Prefix extends string = "pp"
      • const Method extends "camarilla" | "standard" | "fibonacci" | "woodie" = "standard"

      Parameters

      Returns PivotPointsResult<S, Prefix, Method>