Code to sell option based on Total price/ Net value

Greetings, How to write code to sell option based on Total price/ Net value.

I bought option CE8000 at Rs.X, if my current position TOTAL AMOUNT/NET VALUE' or profit reaches my target amount(Ex: Rs Y), I need code to auto execute SELL(close)  order at market price. please provide steps to execute back-test the same. It would be help full if you suggest the tool for the same.


I guess you can place a target sell limit order at the desired value .
value you can calculate by: (expected profit)/(number of contracts held) .

Correct me if i am wrong in understanding your question .

Thanks for response, i’ll explain with simple example.
Ex: I bought CE7800, today its trading around Rs.50. I bought 1 lot(25 contract), my invest amount is Rs: 1250. I need CODE to AUTO sell/ close position of CE7800 at market price, if the total amount reaches Rs.1500 or above(i.e if contract price reaches Rs.60) without explicitly placing the contract price.
Hope it help. Thanks for your time.