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/

    Conditionally carry previous value forward operation

    General Code/Help
    1
    2
    21
    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,

      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)))
      
      1 Reply Last reply Reply Quote 0
      • Madhav Patel
        Madhav Patel last edited by

        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

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