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

Bracket order only with Stop

  • I've got following problem: Stop order is supposed to get cancelled automatically if Limit order is executed (also known as OCO) and position closed. In my strategy I do not use Limit order as my profitable positions are closed by the strategy logic. However, I cannot leave a position without a stop order. If I attach a stop or trailing stop and my trade is closed by the logic of the strategy, the stop order remains active and gets executed later. I need some help. I can't implement this part of the code.

  • administrators

    I seem some failing logic here.

    • A half-bracket is applied (only main order and stop order)
    • main order is executed and stop is activated
    • trade opened by main order is closed by a non-related order
    • the stop order remains (as expected and as it would happen in real-life) active

    It seems pointless to use a half-bracket to open the stop if the functionality of the bracket is ignored.

    In any case the bracket code gives you a reference to the orders which are created. When your foreign order closes the trade, you simply have to use the reference you have for the the stop order and call self.cancel(stop_order)

Log in to reply