Total Profit

 
I want to make a auto-hedging script and so on I need it to be able to check the total of my positions and when it goes over some point I want it to close everything.I can probably manage the rest opening inverted positions but I need this part to work before I go any further. I use mt4 btw not mt5 thank you very much for anyone who can help me out
 
 
also can I make it go back to top of the script after a small sleep time? or is it impossible
Reason: