Skip to content
Open RaamTrade

VIDYA — Variable Index Dynamic Average

An EMA whose smoothing constant is scaled by momentum strength: when Chande’s momentum oscillator is stretched the average moves at close to full EMA speed; when momentum washes out it nearly stops. Kaufman’s KAMA does the same job with efficiency instead of momentum.

Signature

VIDYA(period, cmo_period, on=<source>)
Argument Type Required Notes
period int Param or literal Yes Base EMA length. Default 14, bounds 1–400.
cmo_period int Param or literal Yes Momentum window driving the speed. Default 9, bounds 1–100.
on= symbol, OHLCV field, or indicator No Source. Defaults to the trade symbol’s close.

Formula

$$ k = \frac{|\sum \text{gains} - \sum \text{losses}|}{\sum \text{gains} + \sum \text{losses}}, \quad \alpha = \frac{2}{n+1},k $$ $$ \text{VIDYA}t = \text{VIDYA}{t-1} + \alpha,(C_t - \text{VIDYA}_{t-1}) $$

k is |CMO|/100 — 1 in a clean one-way run, near 0 in balanced chop.

Warmup

cmo_period + 1 bars; tracks the close until then.

Reading the value

vidya.value
self.trade.close > vidya.value

Example

class VidyaFollower(Strategy):
"""An average that stalls in chop and accelerates in momentum."""
trade = Symbol()
sizing = FixedCapital()
def execute(self):
vidya = VIDYA(14, 9, on=self.trade)
if self.trade.close > vidya.value and self.trade.is_flat:
self.buy(self.trade, reason="Above VIDYA")
if self.trade.close < vidya.value and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="Below VIDYA")

Notes

  • Tushar Chande’s VIDYA, CMO-driven variant.
  • Proven by an assert-via-trade run on SPY daily (tracked price inside the expected envelope on every bar of a 140-bar run; zero alarm trades).
  • The line can sit still for long stretches — that is the design, not a stuck value.
  • A different recipe from pandas_ta’s vidya(14), not a different scale: measured on a 300-bar tape ours stays about 1.6 % away and never converges to it, because the construction (window offset, seed, weight normalisation) is its own.