Buy or Sell options based on Index analysis

Based on technical analysis on Index I am generating signals but I am unable to write code to buy OTM option. Need help to code this.

Thanks in advance.