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.
-
Hi everyone, I have the following codes where
crossover_exit
should only close when there is an existing long order andcrossunder_exit
should close when there is a ongoing short order. But my results shows that it is closes a trade whenever there is acrossover_exit
orcrossunder_exit
condition, 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()