public CMF(Bars bars, int period, string description)
public static CMF Series(Bars bars, int period)
||The Bars object
||Indicator calculation period
Chaikin Money Flow (CMF) is a volume weighted average of Accumulation/Distribution over the specified period. The standard CMF period is 21 days. The principle behind the Chaikin Money Flow, is the nearer the close is to the high, the more accumulation has taken place. Conversely the nearer the close is to the low, the more distribution has taken place. If the price action consistently closes above the bar's midpoint on increasing volume then the Chaikin Money Flow will be positive. Conversely, if the price action consistently closes below the bar's midpoint on increasing volume, then the Chaikin Money Flow will be a negative value.
- A CMF sell signal occurs when price action develops a higher high into overbought zones and the CMF diverges with a lower high and begins to fall.
- A CMF buy signal occurs when price action develops a lower low into oversold zones and the CMF diverges with a higher low and begins to rise.
- A CMF value above the zero line is a sign of strength in the market, and a value below the zero line is a sign of weakness in the market.
- The Chaikin Money Flow provides excellent breakout confirmation. Wait for the CMF to confirm the breakout direction of price action through trendlines or support and resistance lines. For example, if price breaks upwards through resistance then wait for the CMF to have a positive value, thus confirming the break out direction.
CMF = n-day Sum of ( ( ( (C - L) - (H - C) ) / (H - L) ) x Vol ) / n-day Sum of Vol
n = number of periods, typically 21
H = high
L = low
C = close
Vol = volume
public class MyStrategy : WealthScript
// Thank you fundtimer
public Color WS4ColorToNET( double WS4Color )
(int)Math.Floor( ( WS4Color % 1000 ) / 100 * 28.4 ),
(int)Math.Floor( ( WS4Color % 100 ) / 10 * 28.4 ),
(int)Math.Floor( WS4Color % 10 * 28.4 ) );
protected override void Execute()
// Use strength of CMF above zero to color bars
double x = 0;
ChartPane CMFPane = CreatePane( 40, true, true );
PlotSeries( CMFPane, CMF.Series( Bars, 20 ), Color.Blue, WealthLab.LineStyle.Histogram, 1 );
SetBarColors( Color.Silver, Color.Silver );
for(int bar = 20; bar < Bars.Count; bar++)
x = CMF.Series( Bars, 20 )[bar] * 20;
if( x > 0 )
SetBarColor( bar, WS4ColorToNET( x ) );