import { CircularBuffer } from './providers/circular-buffer' ; export class SMA { private circular : CircularBuffer ; private sum = 0 ; constructor ( private period ) { this . circular = new CircularBuffer ( period ) ; } nextValue ( value ) { this . circular . push ( value ) ; this . sum += value ; if ( ! this . circular . filled ) { return ; } this . nextValue = ( value ) => { this . sum = this . sum - this . circular . push ( value ) + value ; return this . sum / this . period ; } ; this . momentValue = ( value ) => { return ( this . sum - this . circular . peek ( ) + value ) / this . period ; } ; return this . sum / this . period ; } momentValue ( value ) { return ; } }