For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Trades Observer with multiple trades/products
-
Hi,
if there are multiple trades on different products, then pnlplus and pnlminus in Trades observer will hold just the pnl of the last trade traversed.
def next(self): for trade in self._owner._tradespending: if trade.data not in self.ddatas: continue if not trade.isclosed: continue if trade.pnl >= 0: self.lines.pnlplus[0] = trade.pnl else: self.lines.pnlminus[0] = trade.pnl
I guess something like this is needed
def next(self): for trade in self._owner._tradespending: if trade.data not in self.ddatas: continue if not trade.isclosed: continue if trade.pnl >= 0: self.lines.pnlplus[0] = np.nansum([self.lines.pnlplus[0], trade.pnl]) else: self.lines.pnlminus[0] = np.nansum([self.lines.pnlminus[0], trade.pnl])
I am using version 1.9.70.122 in case that is relevant.
Cheers