Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    Indicators/Strategies/Analyzers
    2
    2
    942
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Anil Bhatt last edited by Anil Bhatt

      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.

      B 1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators @Anil Bhatt last edited by

        @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 ...

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors