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/

    multiple stocks order

    Indicators/Strategies/Analyzers
    2
    5
    511
    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.
    • S
      Sam last edited by

      Hi, I wanted to buy two stocks under dfferent condistions. The thing is data0 works , data1 doesn't , thanks for your time!!!

          def next(self):
              for i, d in enumerate(self.datas):
                  if i==0:
                     if self.leida0.today > 0 and self.leida0.lastday<0:
      
                         o1 = self.buy(data=d)
                  if i==1:
                     if  self.leida1.today > 0 and self.leida1.lastday<0:
      
                          o2 = self.buy(data=d)
      
      1 Reply Last reply Reply Quote 0
      • S
        Sam last edited by

        stock1 has buy signal (the green triangle)
        but stock 2 doesn't

        Figure_0.png

        1 Reply Last reply Reply Quote 0
        • S
          Sam last edited by

          OK I realized, actually the transaction of stock2 completed, Why is there no buy signal --- the green triangle ?

          1 Reply Last reply Reply Quote 0
          • A
            ab_trader last edited by

            Try to use addobservermulti to have BuySell observer applied to several data feeds.

            https://community.backtrader.com/post/1857

            S 1 Reply Last reply Reply Quote 1
            • S
              Sam @ab_trader last edited by

              @ab_trader Thank you so much!

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