Exiting all positions in one click

If I select all positions to exit in one click then how would the system execute the trades?
As per the new margin rule, it would be a good idea to exit from high-risk trades first and then low-risk trades so if for example I have created only an iron fly then while exiting from all 4 legs one by one there may be a chance that the price may move adversely within few seconds, so to avoid this if I select all 4 legs and exit in one go then would the system automatically firstly identify high-risk trades to take an exit from them then low risk or it can execute orders randomly?

@siva

can you please throw some light?

thanks

No, system can’t recognize, any order can go through first, maybe use basket orders so that orders will go in order, top order first.

@siva
If we exit hedged trade positions in one click and system squares off the buy position first and sell positions after that, then there will be margin requirement for some seconds. Will this attract peak margin penalty? If so, how to remediate that? DO we need to exit sold positions first? Please throw some light

It will be in split of sec, like milli sec difference, but yes better to exit shorts first and longs later if hedge position is involved.

while getting into the position i can place all 4 orders via basket order but how do we exit from position via basket order?

Create new basket again and place.