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/

    creating indicator if condition is met in next()

    Indicators/Strategies/Analyzers
    2
    3
    143
    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.
    • V
      vaclavku last edited by

      Hello everyone, anyone can provide me with a hint:
      My intention is to create "indicator" based on the sum of the values only in case a condition is met in the next().
      Specifically: I'd like to use the SumN if self.position.
      When I run it, I get this error:
      TypeError: must be real number, not SumN.
      The question is how to get value out of:
      <class 'backtrader.indicators.basicops.SumN'>
      (The index [0] doesn't work for me as "TypeError: 'float' object is not subscriptable")

      B 1 Reply Last reply Reply Quote 0
      • V
        vaclavku last edited by

        Hello everyone, if anyone interested I solved this out with self.feed.get() and numpy.sum().

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

          @vaclavku said in creating indicator if condition is met in next():

          When I run it, I get this error:

          When you run what?

          @vaclavku said in creating indicator if condition is met in next():

          if anyone interested I solved this out with self.feed.get() and numpy.sum().

          What did you actually solve? Because there was nothing showing what you were attempting.

          @vaclavku said in creating indicator if condition is met in next():

          if self.position.

          That won't work inside an indicator because an indicator per se has no notion of a position.

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