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 efficient to compare one Indicator base on multi datafeed

    General Code/Help
    1
    2
    18
    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.
    • chandler song
      chandler song last edited by

      if I have 2 data feeds, google and facebook.

      self.google_pct = bt.indicators.RateOfChange(self.datas[0].close, period=1)
      self.facebook_pct = bt.indicators.RateOfChange(self.datas[1].close, period=1)
      

      what I want to do is to buy which has bigger pct. like below

       if self.google_pct[0] > self.facebook_pct[0]:
          buy google
      else:
         buy facebook
      

      if there are n data feeds, what's the efficient way to find the data feed with max pct?

      1 Reply Last reply Reply Quote 0
      • chandler song
        chandler song last edited by

        add more comment to make my question clear.

        what I want to do is compare multi Indicator to get max one

        self.one_pct = bt.indicators.RateOfChange(self.datas[0].close, period=1)
        self.two_pct = bt.indicators.RateOfChange(self.datas[1].close, period=1)
        self.three_pct = bt.indicators.RateOfChange(self.datas[2].close, period=1)
        .....
        self.n_pct = bt.indicators.RateOfChange(self.datas[n-1].close, period=1)
        

        what I want to do is find the max one and buy like below

        max_stock=findMaxpct()
        self.buy(data=max_stock)
        

        how to implement the find_max_pct efficient?

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