For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
How to access last indicatior value in __init__()
-
class SomeStrategy(bt.Strategy): def __init__(self): self.sma = bt.indicators.SMA(self.datas[0]) #how to write here: self.sig = (sma_two_days_go>sma_one_days_go & sma_two_days_go< sma_today)
I know how to do it in "def next()", but don't know to do it in init
-
Sorry , mistyping, It should be:
self.sig = (sma_two_days_ago>sma_one_days_ago & sma_two_days_ago< sma_today)
-
@dindom999 Just use
()
brackets in init.self.sig = (self.sma(-2) > self.sma(-1)) & (self.sma(-2) < self.sma)
-
@run-out It works, thanks!!!