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/

    express 2 conditions in a efficient way

    General Code/Help
    2
    5
    887
    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.
    • H
      hobart-liu last edited by

      Say if I try to check, trix.trix cross trix.signal and trix.trix < 0, How to write it in an efficient way.
      I know I can use CrossOver(trix.trix, trix.signal), but how to add another condition, trix < 0

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

        Operator and cannot be overridden in Python, hence the need to have something specific.

        trix1 = bt.ind.CrossOver(trix.trix, trix.signal)
        trix2 = trix < 0
        mytrixsignal = bt.And(trix1, trix2)
        
        1 Reply Last reply Reply Quote 1
        • H
          hobart-liu last edited by

          thanks! so fast! :-)

          1 Reply Last reply Reply Quote 0
          • H
            hobart-liu last edited by

            BTW, how to initialize a line with 0?

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

              That question probably needs elaboration. It seems out of context ...

              Lines are not initialized. They are filled with values during next (and prenext before the warm-up period is over)

              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(); }); }