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 do I access the Trade object from within the next() method of Strategy?
-
I would like to keep track of the time I am currently in the trade. I know that the trade object has a
barlen
attribute. I would like to check for it in thenext()
method of the Strategy. How do I do it? -
I was doing the following:
def notify_trade(self, trade): if trade.justopened: self.trade_length = 0 if trade.isclosed: self.trade_length = None def next(self): pos = self.getposition() if pos: self.trade_length += 1