Empty4 doesn't support entering OCO orders. You can enter a Pending Order with attached TP/SL, and the TP/SL are effectively OCO. But I want to be able to enter two POs above & below the current price, each with their TP/SL, and have the two POs be OCO.
So I looked around a bit and found some OCO scripts, and modified one slightly for my particular needs. (So I don't take blame or credit for most of the code in this thing.) But I'm running into a few problems:
* It passes arrow color values to OrderSend, which draws arrows &etc on the chart. Fine. But it doesn't clean up after itself. When the buy stop got hit, the signal arrows & line & various other bits get left on the chart. How can I fix that, without having to delete the objects manually? The original code didn't pass arrow color to the OrderClose / OrderDelete functions, but it didn't improve when I added them.
* Sometimes I want to cancel my orders. I don't see a good way to do that. I added a deinit() to the script, thinking I could just remove the script and let the deinit cancel the orders. But that had the unfortunate result of closing the order immediately after hitting the buy/sell stop. Whoops. Plus (after removing the deinit) when I remove the script, it just starts flashing the "OCO script running" message faster. If I remove it again it kills the script, but there's no deinit() to cancel the orders. What's a good way to do this without having to do everything manually?
Is there a better way to handle this for manually-placed orders? Or does somebody have a better script? I haven't been able to spend much time learning MQL yet so I'm not quite clueful enough to write a proper EA for this.
Thanks,
Gary