Total Order Count both Pending order and running trades
-
I want my ea to be able to count all the existing orders, both trades and pending order. Then close all trades and delete all pending orders if their total number is less than an input value
Say for instance input value for total orders = 30, if trades is 6 and pending order is 24 nothing happens
But if trade is 1 and pending order 19 for instance, they all close since it doesn't sum up to 30
Please I've been trying to do this for days


-
I don't understand the logic behind that. Are you ready to close 19 open trades in loss just because it is below 30? What is the point of that?
-
@l-andorrĂ I said 1 trade and 19 pending orders. And yes I'm ready to close it all just because their sum is below 30... Here's the reason.
I'm using a trailing stop for group of orders. When the trailing stop is activated, everything is supposed to be deleted as I'm also using the check stop loss then delete order and close losable trades blocks. However, sometimes slippage or because the trades hit stop loss as soon as it is modified cause for only the modified orders to close and the pending orders just stay there while losable trades stay open and continue to run in loss.
So I need a way to close them all if they are less than a certain number. That way the ea keep searching to see if they are less than a certain number and close all