How to code Universal exit if combined profit is 25%

Hi,
I want to execute Nifty / Banknifty short straddle and exit the position if the combined profit is 25% (i.e. PnL of leg 1 + PnL of leg 2 = 25%)

Can anyone please help?