If I have written a option contract, say for example contract X for 50 Rs and the underlying price direction is going against me and now the X is at 52. now I want to do set up automatic stop-loss order for my sold contract at 55.
To close this position, I have to buy back if the price touches 55 (but now it is 52!), In reality I cant create buy order at 55 when X is trading at 52. then how can i set up automatic stop loss order this case?
It is not an automatic stoploss, you are looking at creating just a normal stoploss order. Check this post.
You place a SL order to buy either a limit price of around 55 or market price, but this order will get activated only once the trigger is hit. So in your case, you can set the trigger price as 55, and place either a Stoploss with limit or market.