For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

How to calculate Chaikin Money Flow



  • I'm trying to calculate Chaikin Money flow class but unable to match result with excel calculation, can someone help me here :

    1. Money Flow Multiplier = [(Close - Low) - (High - Close)] /(High - Low)

    2. Money Flow Volume = Money Flow Multiplier x Volume for the Period

    3. 20-period CMF = 20-period Sum of Money Flow Volume / 20 period Sum of Volume

    def __init__(self):
    
        # Let the indicator get enough data
        self.addminperiod(self.p.len)
    
        # Aliases to avoid long lines
        c = self.data.close
        h = self.data.high
        l = self.data.low
        v = self.data.volume
    
        self.data.ad = ((((c  -  l) - (h - c)) / (h - l) ) * v)
        self.lines.money_flow = bt.indicators.SumN(self.data.ad, period=self.p.len) / bt.indicators.SumN(
            self.data.volume, period=self.p.len)
    

    final calculation is different from excel calculation. Can any one pls help here.


  • administrators

    @anil-bhatt said in How to calculate Chaikin Money Flow:

    # Let the indicator get enough data
    self.addminperiod(self.p.len)
    

    That's not needed and it will probably hurt. But without knowing how and when the values differ ...