export class Momentum { public static calculate ( periods , length , source = 'close' ) { return this . calculateValue ( periods . map ( ( p ) => p [ source ] ) , length ) ; } public static calculateValue ( values , length ) { if ( ! values . length || values . length <= length ) return 0 ; return values [ 0 ] - values [ length ] ; } }