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