Skip to content
Open RaamTrade

AccumulativeSwingIndex — Accumulative Swing Index

Wilder’s swing index, accumulated. Each bar’s swing index compares the current open/close to the previous bar’s, scaled by the larger of the two gaps; summing them gives what Wilder called a proxy for the “real” price line behind the noise. Trendlines drawn on the ASI are the classic use.

Signature

AccumulativeSwingIndex(lookback, limit_move, on=<source>)
Argument Type Required Notes
lookback int Param Yes Pinned at 1 (the indicator keeps only the previous bar). Bounds 1–1.
limit_move float Param or literal Yes Wilder’s limit-move scaling constant. Default 1.0, bounds 0.0001–100000.0.
on= symbol No Source symbol. Defaults to the trade symbol. Reads open, high, low, close.

Formula

$$ SI = 50,\frac{(C - C_p) + 0.5(C - O) + 0.25(C_p - O_p)}{R}\cdot\frac{K}{L}, \quad \text{ASI}t = \text{ASI}{t-1} + SI_t $$

with K the larger of |H − Cₚ| and |L − Cₚ|, R selected by Wilder’s three-case rule, and L the limit move.

Warmup

Starts at 0 on the first bar; accumulates thereafter. Resets per run and per walk-forward window.

Reading the value

asi.value
asi.value > asi.value_at(20)

Example

class AsiTrend(Strategy):
"""Follow the accumulated swing line rather than raw price."""
trade = Symbol()
sizing = FixedCapital()
def execute(self):
asi = AccumulativeSwingIndex(1, 1.0, on=self.trade)
if asi.value > asi.value_at(20) and self.trade.is_flat:
self.buy(self.trade, reason="ASI rising")
if asi.value < asi.value_at(20) and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="ASI rolling over")

Notes

  • Wilder, New Concepts in Technical Trading Systems (1978).
  • limit_move was Wilder’s daily-limit constant for commodity contracts. On instruments with no limit, leave it at 1.0 and read the ASI’s shape, not its absolute level.