fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Chaikin Money Flow

Install and import#

bash
npm install fintech-algorithms
ts
import { chaikinMoneyFlow } from "fintech-algorithms/technical-indicators/volume-indicators/chaikin-money-flow";

Signature#

chaikinMoneyFlow(high, low, close, volume, p)

Money-flow volume summed over a lookback and divided by total volume over the same window — the accumulation/distribution idea as a bounded oscillator rather than a running total.

Parameters#

NameTypeNotes
highnumber[]Per-bar high prices, chronological.
lownumber[]Per-bar low prices, chronological.
closenumber[]Per-bar closing prices, chronological.
volumenumber[]Per-bar traded volume, aligned index-for-index with the price series.
pnumberLookback in bars.
min: 1 · integer: true

Returns#

Record<string, (number | null)[]> · length same-as-input

Parallel series: money_flow_multiplier, money_flow_volume, rolling_mfv, rolling_volume and cmf.

Warm-up#

The first p − 1 positions are null.

Errors#

  • When p < 1 or is not an integer — throws RangeError
  • When the input series are not all the same length — throws RangeError

Complexity: time O(n), space O(n).

Worked example#

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input#

high
[101.05, 101.52482, 102.098461, 102.729464, 103.36806, 103.963227]

Showing 6 of 120 elements.

low
[99.4, 99.462904, 99.936275, 100.512674, 101.151059, 101.802588]

Showing 6 of 120 elements.

close
[100.28, 100.686113, 101.200346, 101.789282, 102.408843, 103.010585]

Showing 6 of 120 elements.

volume
[990000, 1066468.036, 1130033.236, 1170141.961, 1180511.26, 1160272.794]

Showing 6 of 120 elements.

Call#

chaikinMoneyFlow(high, low, close, volume, p)

Returns#

object with 5 fields: money_flow_multiplier, money_flow_volume, rolling_mfv, rolling_volume, cmf

{
  "money_flow_multiplier": [
    0.06666666666666667,
    0.1864780136533253,
    0.16925278398805474,
    0.1517626838807486,
    0.1346715675816141,
    0.118184944361371
  ],
  "money_flow_volume": [
    66000,
    198872.84097804304,
    191261.2711920305,
    177583.88452284224,
    158981.30193194642,
    137126.7756029025
  ],
  "rolling_mfv": [null, null, null, null, null, null],
  "rolling_volume": [null, null, null, null, null, null],
  "cmf": [null, null, null, null, null, null]
}

Other exports#

This module also exports obv, accumulationDistributionLine, moneyFlowIndex, volumePriceTrend, forceIndex. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams#

Chaikin Money Flow — chaikin money flow comparison
Chaikin Money Flow — chaikin money flow mechanism

Calculation flow#

Calculation flow
flowchart LR
  A["Finalized finalized high, low, close, and nonnegative volume"] --> B["Validate order, alignment, and finite values"]
  B --> C["Close-location multiplier"]
  C --> D["Money-flow volume"]
  D --> E["Rolling numerator / denominator"]
  E --> F{"History and denominator valid?"}
  F -- "No · short history" --> G["warming-up + reason"]
  F -- "No · no finite scale" --> H["undefined + reason"]
  F -- "Yes" --> I["Chaikin Money Flow"]
  I --> J["ready + aligned component trace"]
Data-basis reconciliation — Chaikin Money Flow
flowchart LR
    A["Same instrument and identifier?"] -->|Yes| B["Same venue or consolidated scope?"]
    A -->|No| X["Stop: different measurement"]
    B -->|Yes| C["Same volume unit and bar interval?"]
    B -->|No| X
    C -->|Yes| D["Same session and close policy?"]
    C -->|No| X
    D -->|Yes| E["Same corrections and price-volume adjustment basis?"]
    D -->|No| X
    E -->|Yes| F["Same CMF convention, seed, warm-up, and precision?"]
    E -->|No| X
    F -->|Yes| G["Compare intermediate components"]
    F -->|No| Y["Document convention difference"]
    G --> H["Compare final output"]

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

  • Chaikin Money Flow — Chaikin Analytics
  • Chaikin Oscillator — TradingView
  • Volume — TradingView
  • Consolidated Tape — U.S. Securities and Exchange Commission, Investor.gov
  • Closing Price — U.S. Securities and Exchange Commission, Investor.gov
  • What is Volume? — CME Group
  • Claim-role ledger
  • Evidence boundary
  • Enhanced claim-to-source map
  • Public evidence boundary

The rest of the Volume Indicators family#