Margin requirements calculation

 

I have come across an issue to get my trading strategy sustainable, which is the calculation of margin requirements when i'm implementing grid and hedging in the same time. what i have noticed that during applying grid trades i.e opening buy positions one after the other with gap, the margin is calculated in normal way considering my broker leverage of 1:500. But, once the first hedge order is placed i.e sell order then the margin calculation get changed.

Does anybody have suitable tool or excel sheet for multiple trades margin calculation?