Is there a way to cancel a specific order using generic broker functions? cancelOrder() cancels all open orders for a given ticker.
I want to enter a position via a market order with an integrated broker and immediately send a StopLimit order for a profit target and a StopLimit order for a stop loss.
Then I want to trail the stop loss StopLimit order. To do this, I need to cancel the existing stop loss StopLimit order and place the new trailed one. When doing the cancel, I am also canceling the profit target StopLimit order which I do not want to do.
Yes, I can replace the profit target StopLimit order each time I trail, however, in some instances replacing the order may not be accepted by the exchange as its price may have been passed during the process....then I am sitting with no profit target stop and may not know it. Instead I want to leave the profit target stop in place until it is hit and filled or until the trade gets stopped out via the stop loss StopLimit order.
Which brings up a second question, how will my efs code know when/if an order is filled? I have not found any OnFill kind of functions.
Thanks in advance.
I want to enter a position via a market order with an integrated broker and immediately send a StopLimit order for a profit target and a StopLimit order for a stop loss.
Then I want to trail the stop loss StopLimit order. To do this, I need to cancel the existing stop loss StopLimit order and place the new trailed one. When doing the cancel, I am also canceling the profit target StopLimit order which I do not want to do.
Yes, I can replace the profit target StopLimit order each time I trail, however, in some instances replacing the order may not be accepted by the exchange as its price may have been passed during the process....then I am sitting with no profit target stop and may not know it. Instead I want to leave the profit target stop in place until it is hit and filled or until the trade gets stopped out via the stop loss StopLimit order.
Which brings up a second question, how will my efs code know when/if an order is filled? I have not found any OnFill kind of functions.
Thanks in advance.
Comment