Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. adrtod
    3. Best
    • Flag Profile
    • Block User
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Best posts made by adrtod

    • RE: Must be real number, not LinesOperation

      Consider declaring indicators once in __init__:

      self.HighestC = bt.indicators.Highest(self.data, period=9)
      self.LowestC = bt.indicators.Lowest(self.data, period=9)
      

      and then use

      self.l.Stoc[0] = (self.data[0]-self.LowestC[0])/(self.HighestC[0]-self.LowestC[0])
      posted in General Code/Help
      adrtod
    • RE: Must be real number, not LinesOperation

      Alternatively in __init__ only:

      HighestC = bt.indicators.Highest(self.data, period=9)
      LowestC = bt.indicators.Lowest(self.data, period=9)
      self.l.Stoc = (self.data-LowestC)/(HighestC-LowestC)
      posted in General Code/Help
      adrtod
    • RE: Must be real number, not LinesOperation

      __init__ is called only once and only declares the indicators as objects, no computation is done during __init__ but they are handled automatically.
      The same applies when using operators to combine indicators, see https://www.backtrader.com/docu/concepts.html#operators-using-natural-constructs
      See also https://www.backtrader.com/docu/induse.html and https://www.backtrader.com/docu/inddev.html

      posted in General Code/Help
      adrtod
    • 1 / 1