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



  • 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)))
    


  • 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


Log in to reply
 

});