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?
Kristofer Monisit last edited by
I would like to keep track of the time I am currently in the trade. I know that the trade object has a
barlenattribute. I would like to check for it in the
next()method of the Strategy. How do I do it?
ab_trader last edited by
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