Creating one stop loss for all active order

 
I would like to create a stop loss facility that once hit it will flat all the open position for a specific instrument, the distance should be in Pips. To make thing clearer, I am using a scale in approach,yet I want to get out of the entire position if any of the open trades pass the stop loss limit . I was unable to find a function that will flatten everything.
 

Borrow the AllProfit function from here https://www.mql5.com/en/code/9156

And when the Profit is negative to the amount of your stop loss, use the CloseAll functions in this https://www.mql5.com/en/code/8714

NB - you will have to convert currency to pips for each symbol

Good Luck

-BB-

 
BarrowBoy:

Borrow the AllProfit function from here https://www.mql5.com/en/code/9156

And when the Profit is negative to the amount of your stop loss, use the CloseAll functions in this https://www.mql5.com/en/code/8714

NB - you will have to convert currency to pips for each symbol

Good Luck

-BB-

Thanks this is very helpful .One question though. You use the OrderMagicNumber function and compare it with the iMagic variable you created. I don't understand why you conduct this test.

Reason: