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/

    CrossOver value for boll.lines.top (lines object) always returns 0

    General Code/Help
    2
    4
    112
    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
      tx_562 last edited by

      Running into an error where bt.ind.CrossOver(self.data.close, self.boll.lines.top) will always return 0, despite multiple crosses, however,
      bt.ind.CrossOver(self.data.close, self.boll) returns -1, 0, and 1 values properly. It doesn't seem to return any values from the 'lines' object?

      def __init__(self):
          self.boll = bt.ind.BollingerBands(period=3, devfactor=2)
          self.tcrx = bt.ind.CrossOver(self.data.close, self.boll.lines.top)
      
      def next(self):
          print(self.tcrx[0])
      
      run-out 1 Reply Last reply Reply Quote 0
      • run-out
        run-out @tx_562 last edited by

        @tx_562 said in CrossOver value for boll.lines.top (lines object) always returns 0:

        bt.ind.CrossOver(self.data.close, self.boll.lines.top)

        I think you want mid. The close won't go over the top.

        RunBacktest.com

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

          If you reduce the devfactor or increase the period you'll start to get hits on the top and bottom.

          RunBacktest.com

          T 1 Reply Last reply Reply Quote 1
          • T
            tx_562 @run-out last edited by

            @run-out Thank you! Looks like 'high' is giving me the proper values. Would the 'self.data.close' price be the 'current price' if I'm running replaydata?

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