@Lacone I'm still confused 
There's a block, trades count and another pending order count, is there a way to use the results from these blocks in a formula? So I can simply add them up to get the total order
@Lacone I'm still confused 
There's a block, trades count and another pending order count, is there a way to use the results from these blocks in a formula? So I can simply add them up to get the total order
A trade can close by stop loss (trailing stop) so only then, only when the trades are less than 30 should all trades close
But the variable should only be zero when there are no existing trades.. because the ea has two strategies. If the last closed trades had no stop loss modified (close by TP), then the ea would not do anything to existing orders... But if stop loss of last closed trade was modified and trades total is less than 30, then everything but running trades and pending order gets closed... Only then should the variable reset to 0.
There's a block, trades count and another pending order count, is there a way to use the results from these blocks in a formula?
@Lacone Thank you, i'm taking a look at it now
@Morpheus_0 Thank you so much, it is becoming clearer and clearer now, however in the ontrade tab, if one trade just close, it modifies the variable to zero? should it not be only when all the trades close?
o I'm beginning to see, but please can you say more? 
@Morpheus_0 It's alright, I get the inequalities (less than or equal to). Still don't understand how you defined those variables (trades, orders) what is trades? Does the ea recognize trades to mean total open orders?
@Morpheus_0 I've seen the variable but I still don't get it though.. when creating them is there a way I'll tell the ea that this variable means total open trades?
@Lacone please share a project link
@Lacone please how can I define a variable? Like is I want to define a variable to count all running trades and another to count all running orders. And my ea is MT4
Please I don't know how to define a variable and I'll like an explanation on that. Like I'll like to define a variable for trade count (to count all open orders) and to define a variable for all pending orders so that I can use the formula block to get their sum 

@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
@Morpheus_0 I don't understand many things there... First the formula, then the on trade events but let me start with the formula
How does the ea tell that the variable, Trade means total number of trades and that the variable Orders means total number of pending orders? This is where the basis of my confusion is
@Morpheus_0 very frustrating indeed. Let me take a look at what you shared. I'll reply
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 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 need help