For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Problem with too many closing trades.
Jeffrey C F Wong last edited by
Hi everyone, I have the following codes where
crossover_exitshould only close when there is an existing long order and
crossunder_exitshould close when there is a ongoing short order. But my results shows that it is closes a trade whenever there is a
crossunder_exitcondition, resulting in too many closes. It'd be great if someone can shine some light on this. Thank you in advance.
if not self.position: if self.crossover: self.buy() if self.crossunder: self.sell() if self.position.size!=0: if self.position is self.buy and self.crossover_exit: self.close() if self.position is self.sell and self.crossunder_exit: self.close()