Chaikin Money Flow on TradingView
The Chaikin Money Flow index (CMF) measures where bars close within their high-low ranges, weighted by volume over a rolling window. A positive value favors upper-range closes; a negative value favors lower-range closes. It is a price-and-volume proxy for pressure, not a record of cash entering or leaving an asset.
Start with the calculation and the feed behind it. A gap down can still produce positive money flow, and an unfinished bar can move across zero before closing.
Inspect the Pine Script exampleCMF formula: position first, volume second
Multiplier = (2 × Close - High - Low) / (High - Low)
Money Flow Volume = Multiplier × Volume
CMF(N) = Sum(Money Flow Volume, N) / Sum(Volume, N)The multiplier is +1 at the high, 0 at the midpoint and -1 at the low. With valid nonnegative volume and a positive total, CMF is a weighted average bounded by -1 and +1. The official CMF calculation uses a rolling lookback, rather than a cumulative total from the start of the chart.
| Bar | High / Low / Close | Volume | Multiplier | Flow |
|---|---|---|---|---|
| A | 110 / 100 / 108 | 1,000 | +0.60 | +600 |
| B | 108 / 98 / 100 | 3,000 | -0.60 | -1,800 |
CMF(2) = (600 - 1,800) / (1,000 + 3,000) = -0.30. There is one upper-range close and one lower-range close, but the second bar carries three times the weight. Counting positive bars would miss that difference. These are illustrative numbers, not historical market data or trade results.
A zero-range bar makes the raw multiplier undefined. The example below assigns that bar zero money flow and retains its reported volume in the denominator. Missing volume invalidates the whole window; an all-zero volume window has no CMF value.
CMF vs MFI vs ADL
| Indicator | What sets the direction? | Aggregation | Reading |
|---|---|---|---|
| CMF | Close within the current range | Rolling MFV divided by rolling volume | -1 to +1; zero reference |
| MFI | Typical price rising or falling versus the prior bar | Positive/negative typical-price × volume ratio | 0 to 100; often compared with 80/20 |
| ADL | Same range multiplier as CMF | Running sum of MFV | Unbounded; direction and changes matter |
MFI uses typical price, (high + low + close) / 3. An upper-range close can still have a lower typical price than the previous bar, so positive CMF contribution and negative MFI flow can coexist. MFI's 80/20 thresholds do not transfer to CMF.
ADL retains earlier contributions; CMF drops them when they leave its window. In the two-bar example above, ADL changes by -1,200 shares of weighted flow, while CMF reports the normalized -0.30. Changing the start of the dataset changes ADL's starting level. It does not change a later CMF window with identical bars.
For the oscillator's own calculation and examples, see the MFI guide. OBV offers another comparison: its direction follows close-to-close changes rather than CMF's close-within-range multiplier.
Why gaps and intraday volume change the reading
A gap down can add positive money flow
Suppose yesterday closed at 100. Today opens at 90, trades from 88 to 94, then closes at 93 with 12,000 shares of volume. Its multiplier is (186 - 94 - 88) / 6 = +0.667, and its money flow volume is +8,000. Price fell 7% from the previous close, yet this bar contributes positively to CMF. The final CMF still depends on the other bars in its window.
This hypothetical example follows the formula: the previous close is absent. ADL shares the same gap limitation. A positive CMF contribution cannot by itself establish that the overnight decline has reversed.
Bar volume is different from a session total
On a five-minute chart, volume belongs to each five-minute bar. During the open bar it accumulates from that bar's opening update; it is not the entire day's volume. A 20-bar CMF rolls across 20 available bars and does not automatically reset at the session open. See TradingView's chart data documentation.
Consider two illustrative intraday bars with multipliers +1 and -1 and volumes 100 and 300. Their two-bar CMF is -0.50. Substituting session-cumulative volumes of 100 and 400 produces -0.60: the first bar's volume is counted again. Do not feed a running daily volume total into the standard CMF formula.
Calculating CMF from daily OHLCV is also different from summing intraday MFV: a daily bar has one high-low range and one closing position. Keep symbol, provider, timeframe and session settings fixed when comparing results. Extended-hours bars can change both the window and its weights.
Check what the feed reports. TradingView documents symbols with missing volume or tick volume. A tick count describes price-update activity. It is not interchangeable with a traded-share total, and one exchange's crypto volume is not a consolidated total across all venues.
Pine Script v6: CMF with confirmed zero crosses
This educational indicator uses a 20-bar CMF and an optional 50-bar simple moving average of price. A long candidate requires a cross above zero and a close above the SMA; a short candidate requires the reverse. Both require a closed bar. The periods are example inputs, with no performance claim.
//@version=6
indicator("CMF with confirmed zero crosses", overlay = false)
length = input.int(20, "CMF length", minval = 1)
trendLength = input.int(50, "Price SMA length", minval = 1)
usePriceFilter = input.bool(true, "Require price above/below SMA")
// Zero-range bars contribute zero money flow, but retain their volume weight.
multiplier = high == low ? 0.0 : (2.0 * close - high - low) / (high - low)
invalidVolume = na(volume) or volume < 0
barVolume = invalidVolume ? 0.0 : volume
volumeSum = math.sum(barVolume, length)
flowSum = math.sum(multiplier * barVolume, length)
invalidCount = math.sum(invalidVolume ? 1.0 : 0.0, length)
validWindow = bar_index >= length - 1 and invalidCount == 0 and volumeSum > 0
cmf = validWindow ? flowSum / volumeSum : na
priceSma = ta.sma(close, trendLength)
crossUp = ta.crossover(cmf, 0.0)
crossDown = ta.crossunder(cmf, 0.0)
longCandidate = barstate.isconfirmed and crossUp and (not usePriceFilter or close > priceSma)
shortCandidate = barstate.isconfirmed and crossDown and (not usePriceFilter or close < priceSma)
plot(cmf, "CMF", color = color.blue, linewidth = 2, style = plot.style_linebr)
hline(0, "Zero", color = color.gray)
plotshape(longCandidate, "Long candidate", shape.triangleup, location.bottom, color.green, text = "L")
plotshape(shortCandidate, "Short candidate", shape.triangledown, location.top, color.red, text = "S")
alertcondition(longCandidate, "CMF long candidate", "CMF crossed above zero with the selected price filter at bar close.")
alertcondition(shortCandidate, "CMF short candidate", "CMF crossed below zero with the selected price filter at bar close.")
var table status = table.new(position.top_right, 1, 1)
if barstate.islast
table.cell(status, 0, 0, validWindow ? "CMF uses this chart feed's volume" : "CMF unavailable: check history and volume", text_color = color.white, bgcolor = color.new(color.black, 20))- Open Pine Editor in TradingView, paste the example into a new indicator and add it to a standard candle chart.
- Inspect the Volume pane and compare CMF against the built-in indicator at the same length. The explicit missing-volume policy can produce different availability.
- Wait for enough history: CMF needs its full window; the optional price filter also needs its SMA history. Turning the filter off removes that SMA requirement.
- Create an alert using the long or short candidate condition and select Once Per Bar Close. Recreate alerts after changing the script or inputs.
The line updates during an open candle. Signal markers wait for barstate.isconfirmed. If the SMA filter fails on the crossing bar, a later move above the SMA does not trigger a delayed candidate; another CMF crossing is required. No orders, exits, stops or position sizing are included.
Repeated crosses around zero can whipsaw. A threshold buffer or persistence rule changes the experiment and delays some signals; it needs its own evaluation. Before converting candidates into a strategy, define exits, costs and sizing, then test on data not used to choose the inputs. A divergence alone has no guaranteed reversal date, and automated pivot comparisons require an explicit confirmation delay.
Build a CMF rule in Pineify
Use the AI Coding Agent to draft or revise an explicit rule, then inspect the generated Pine Script in TradingView. Include your volume policy and confirmation timing in the request.
Create a Pine Script v6 CMF indicator with length 20. Mark a cross above zero only at bar close when price is above its 50-bar SMA. Add the symmetric bearish condition. Hide CMF when the lookback contains missing volume or its volume sum is zero. Include alert conditions and explain when no signal can appear.Build a CMF rule with the AI Coding Agent
The Visual Editor also includes CMF with a configurable length and a CMF output for conditions. Check the exported volume handling: its current CMF implementation substitutes 1 when volume is missing. That differs from this example's stricter policy, so use a feed with reported volume and review the output before relying on it.
Educational information, not investment advice. Syntax checks and chart signals do not establish profitability or suitability for a live trade.
Chaikin Money Flow FAQ
Sources and related reading
Official documentation checked October 16, 2026. Numerical examples on this page are hypothetical.
- TradingView: Chaikin Money Flow formula and gap limitation
- TradingView: Money Flow Index calculation
- TradingView: Accumulation/Distribution calculation
- Pine Script: Chart prices, volume and sessions
- Pine Script: Confirmed bar states
- TradingView: Missing, zero and tick volume
- Pine Script: Alert creation and saved inputs
Browse the TradingView indicators category for related calculation and chart guides.