Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Madhav Patel
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 4
    • Best 0
    • Groups 0

    Madhav Patel

    @Madhav Patel

    0
    Reputation
    1
    Profile views
    4
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Madhav Patel Unfollow Follow

    Latest posts made by Madhav Patel

    • RE: Conditionally carry previous value forward operation

      If it helps here is a bit more context. The goal here is to keep the signal bullishg_rolling signal high after we get the first bullish_now signal and until bullish_stop is triggered.

      self.bullish = bt.And(super_fast > fast, fast > slow, self.data_low > super_fast)
      self.bullish_now = bt.And(1 - self.bullish(-1), self.bullish)
      self.bullish_stop = super_fast <= fast
      

      super_fast,fast,slow are EMAs

      posted in General Code/Help
      Madhav Patel
      Madhav Patel
    • Conditionally carry previous value forward operation

      Hello everyone,

      I was wondering if it was possible to conditionally carry values over for a LinesOperation over in init.

      For example something like this?

      self.bullish_rolling = bt.If(self.bullish_stop, False, bt.If(self.bullish, True, self.bullish_rolling(-1)))
      
      posted in General Code/Help
      Madhav Patel
      Madhav Patel
    • RE: Detecting state change for indicator from (0 -> 1)

      Nevermind :)

      self.bullish_now = bt.And(1 - self.bullish(-1), self.bullish)
      
      posted in General Code/Help
      Madhav Patel
      Madhav Patel
    • Detecting state change for indicator from (0 -> 1)

      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)
      
      posted in General Code/Help
      Madhav Patel
      Madhav Patel