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 initialize indicators for each data in self.datas?

    General Code/Help
    2
    2
    25
    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.
    • T
      thomaslee last edited by

      The following create errors

      class PriceRelative(bt.Indicator):
          ''' x_t = Close_t/Close_{t-1} '''
          lines = ('PriceRelative', )
          
          def __init__(self):
              self.lines.PriceRelative = bt.indicators.RateOfChange(self.data.close, period=1)+1
      
      class Test(bt.Strategy):
      
          def __init__(self):
              for a in self.datas:
                  a.relative = PriceRelative(a.data.close)
      

      How can i fix this so that I can initialize my indicator for each data.close?

      1 Reply Last reply Reply Quote 0
      • run-out
        run-out last edited by

        This has been discussed. Try this thread .

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }