How to program to sell an option while Nifty LTP is a particular figure?


I have Pi access and I have recently started using it… I saw others asking for code and all…But no idea how to code for my purpose…hope someone will help.

I want to use code to Exit all Options of different strike rates (either PE or CE) when Nifty’s LTP hits a particular figure. Let me elaborate. Today I wanted to exit all CE options while Nifty was at 8275. In the same manner, I was about to exit all PE options while Nifty LTP was at 8112. How is this possible? I don’t consider the price of options at that time, but just I want to exit whole options at market price. Because its hard to calculate the price of 7800PE when Nifty hits 8112. Hence better to exit at CMP…

It can  be coded in AFL and  requires more info.

Thank you so much…
Let me ask some more light question now.
I want to trade only in two options today-8400CE and 8450PE.
Daylow of 8450PE is 60.20 and that of 8400CE is 62.40
Iam waiting either of above options to hit 57. If 8450PE hits 57, I want to buy 8400CE.
In other way if 8400CE hits 57, I want to buy 8450PE.
Iam sure that both options will not hit 57, so I have to buy the other one with a stoploss of 57.
Can you help me to code this?