Max pain, or the max pain price, is the strike price with the most open contract puts and calls and the price at which the stock would cause financial losses for the largest number of option holders at expiration. The Maximum Pain theory states that an option's price will gravitate towards a max pain price, in some cases equal to the strike price for an option, that causes the maximum number of options to expire worthless. Calculation involves the summation of the rupee values of outstanding put and call options for each in-the-money strike price.
It is useful in determine the range for particular Expriy in which it's going to expired based on OpenInterest(OI) Calculations at each strike and MAX LOSSES occuring at each strikePrice, calculated below for NF weekly expiry.
Post Automation MAX PAIN Range can be calculated for any F&O Script.
Ref link-Visit zerodha/varsity/chapter/max-pain-pcr-ratio
Ref link- Visit nseindia.com/content/indices/white_paper_IndiaVIX.pdf