For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Group orders with transmit but with 2 orders instead of 3?



  • So this will work:

    self.E1 = self.buy(price=entry_price, size=size, exectype=bt.Order.Stop, transmit=False)
    self.SL1 = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=False, parent=self.E1)
    self.TP1 = self.sell(price=TP1_price, size=size, exectype=bt.Order.Limit, transmit=True, parent=self.E1)
    

    This will not:

    self.E1 = self.buy(price=entry_price, size=size, exectype=bt.Order.Stop, transmit=False)
    self.SL1 = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=True, parent=self.E1)
    

    It gives an error saying self.SL1 = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=True) doesn't work because it is unpacked into parent, stop so it's expecting like parent, stop = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=True, parent=self.E1) for some reason, which is not the case if you had 3 like TP1.

    But I just want to group the entry with a stop, without take profit. How should this be done?



  • @booboothefool said in Group orders with transmit but with 2 orders instead of 3?:

    elf.E1 = self.buy(price=entry_price, size=size, exectype=bt.Order.Stop, transmit=False)
    self.SL1 = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=True, parent=self.E1)

    I'm not sure why you are experiencing an error. I've copied your code and working for me.



  • Oh, forgot to mention. It works perfectly fine in backtesting but craps out live.



  • This would create a one sided bracket order, while bt expects both sides. Not really sure why it worked for @run-out but bt broker will pop both sides and fail because only one order is available.



  • I fixed the issue with oanda broker. It will now assume, there is no stopside


Log in to reply
 

});