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/

    Detecting state change for indicator from (0 -> 1)

    General Code/Help
    1
    2
    44
    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.
    • Madhav Patel
      Madhav Patel last edited by

      Hello everyone,

      Might be a fairly novice question. How do I detect when a signal toggles from 0 to 1.

              super_fast = bt.ind.ExponentialMovingAverage(period=self.params.superFastLength)
              fast = bt.ind.ExponentialMovingAverage(period=self.params.fastLength)
              slow = bt.ind.ExponentialMovingAverage(period=self.params.slowLength)
      
              self.bullish = bt.ind.And(super_fast > fast, fast > slow, self.data_low > super_fast)
      

      I tried this but it throws an exception: "TypeError: bool should return bool, returned LineOwnOperation"

      self.bullish_now = bt.And(not self.bullish(-1), self.bullish)
      
      1 Reply Last reply Reply Quote 0
      • Madhav Patel
        Madhav Patel last edited by

        Nevermind :)

        self.bullish_now = bt.And(1 - self.bullish(-1), self.bullish)
        
        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(); }); }