description author tsrnc2 example export class CMF { public static calculate ( periods , length ) { if ( periods . length < length ) return null ; const periodsSlice = periods . slice ( 0 , length ) ; const sumOfVolume = periodsSlice . reduce ( ( sum , { volume } ) => sum + volume , 0 ) ; const moneyFlowVolume = periodsSlice . reduce ( ( sum , period ) => sum + CMF . getMoneyFlow ( period ) , 0 ) ; return moneyFlowVolume / sumOfVolume ; } private static getMoneyFlow ( period ) { const { volume , close , low , high } = period ; return volume * ( ( close - low ) - ( high - close ) ) / ( high - low ) ; } }