Syntax
public CMF(Bars bars, int period, string description)
public static CMF Series(Bars bars, int period)
Parameter Description
bars |
The Bars object |
period |
Indicator calculation period |
Description
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.
Interpretation
- 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.
Calculation
CMF = n-day Sum of ( ( ( (C - L) - (H - C) ) / (H - L) ) x Vol ) / n-day Sum of Vol
where,
n = number of periods, typically 21
H = high
L = low
C = close
Vol = volume
Example
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
// Thank you fundtimer
public Color WS4ColorToNET( double WS4Color )
{
return Color.FromArgb(
(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 ) );
}
}
}
}