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/

    Find the intraday "high" and "low" in 1min bar?

    General Code/Help
    3
    4
    82
    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.
    • A
      Anthony Chow last edited by

      Hello everyone, i am a newbie using backtrader. i would like to ask for some helps.
      i am going do intraday trading in 1mins, how can i find the intraday "high" and "low" in "self"?

      init

      self.datahigh = self.datas[0].high
      

      self

      Dayhigh = max(self.datahigh[:0])
      

      it seems slicing cannot be applied in bt, and how to use get(size=0,ago=??) to find the high at beginning ?

      864329b8-165f-4aa2-bb9d-0515b30aab10-image.png

      1 Reply Last reply Reply Quote 1
      • Ola D
        Ola D last edited by

        @Anthony-Chow said in Find the intraday "high" and "low" in 1min bar?:

        ize=0,ago=??) to find the high at beginning ?

        Dayhigh = max(self.datahigh.get(size=len(self),ago=0))

        I think this will work. Size is the number of candles you want to account for while ago is how many candles ago you want the iteration to end

        Ola D 1 Reply Last reply Reply Quote 0
        • Ola D
          Ola D @Ola D last edited by

          @Ola-D

          Also I think max should be 'Max'. I don't think it should make a difference but the documentation prefers this method

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

            There's a couple of articles that should have enough information to help you along. Try the following and the link outs from within the articles as well:

            • https://www.backtrader.com/blog/posts/2018-02-06-dynamic-indicator/dynamic-indicator/#the-highest-high-since

            • https://community.backtrader.com/topic/850/highest-high-since-position-was-opened

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