Margin Calculation Doubt

Hi all, I have a doubt in Margin calculator.

I sold an NIFTY weekly option last week Option Heading pattern, the Zerodha calculator showed I need 52K to carry forward the position. I had some 55K in my account so I took the position.

On the day 1 I was in a loss of Rs -238 so second day I got a message I am short will margin of 2K, then I added 2.5K.

On the day 2 I was in a loss of Rs - 702 so again I got a message I am short with my fund so pls add fund to avoid auto square Off, so again I added 3K.

On expiry day I got a profit of 2K but I got confused to avoid the auto square off loss I have been adding fund and finally I got profit.

Then how to know the exact amount of Margin required to take 50K position and an approximate amount to take this positions.

Just maintain minimum 10% buffer for safe side, not advised to take position with full 100% capital available.

Thanks Siva…