# next()

Calculates the indicator on the specified input and the previous inputs, updates the internal state of the indicator.

  • Interface
class MidaIndicator {
    next (input: MidaIndicatorIo): Promise<MidaIndicatorIo>;
}
  • Example
import { createIndicator, } from "@reiryoku/mida";

const sma = createIndicator("SMA", { length: 14, });

await sma.next([ 1, 2, 3, ]); // Calculate on 1, 2, 3
await sma.next([ 4, 5, 6, ]); // Calculate on 1, 2, 3, 4, 5, 6

const values = sma.values;
const lastValue = sma.lastValue;