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

    Function movingAverageDeviation

    • Moving Average Deviation — how far the price sits from its own moving average, in price units:

      maDev = price − MA(period)
      

      Appends one column. Positive means price is above its average, and the magnitude is a number of points on the instrument's own scale — which is the whole reason to want this form rather than a percentage: it is directly comparable with an ATR, a Keltner half-width or a stop distance.

      The corpus lists this study as "price − MA, points or percent" (assessment §6.1). The percent form is already shipped, exactly, as disparityIndex: 100·(price − MA)/MA over the same maType menu and the same defaults-shape. Measured over the oracle's closes at (20, sma) and (14, ema), 100·maDev/MA and disparity agree to 0.0 — bit for bit, not to rounding — and the generator asserts that identity so the two cannot drift.

      So a mode option here would be two indicators behind a flag, one of them a duplicate of an existing export: the keltner precedent this package avoids. What ships is the points form only, which is the half that had no name.

      (This reverses a line in disparityIndex's own docstring, which declined the absolute form as "momentum-shaped arithmetic anyone can write". It is not quite: momentum is price − price[−period], a lagged price, where this is price − MA(period), a smoothed one, and the corpus names it as a study of its own. The two studies are now the two halves of one pair and each points at the other.)

      TA-Lib has no Moving Average Deviation, so the oracle is a pandas replication reusing the TA-Lib-verified K2 engine replication for the average, with the analytic first-valid bar asserted and two discriminating checks: the identity with disparityIndex above, and a separation from momentum (price − price[−period]), which is the wrong turn that leaves the shape intact.

      • Warm-up is the average's, per the K2 engine's table — bar period − 1 for the window types and ema, later for dema / tema / hull / kama / zlema. Length-preserving.
      • Linear in price: scaling every price scales the reading, and — unlike disparityIndexshifting every price leaves it unchanged, because the constant cancels between the price and its own average. Both pinned as property tests, and the shift half is exactly what the percent form does not satisfy.
      • No zero-denominator case at all. There is no division, which is the other half of why the two forms are separate studies rather than a flag: disparityIndex has to answer "what does a zero average mean" and this never asks.
      • A leading gap shifts the start for every maType except 'sma', which keeps sma()'s row-counting window (the column door's documented asymmetry). An interior gap costs whatever the chosen maType costs — window types recover, ema skips, smma and kama propagate — plus the bar's own missing price.

      Type Parameters

      • S extends SeriesSchema
      • const Output extends string = "maDev"

      Parameters

      Returns TimeSeries<
          readonly [S[0], ValueColumnsForSchema<S>, OptionalNumberColumn<Output>],
      >