This algorithm implements a credit spread strategy using volatility viscosity scoring to identify optimal market conditions. It calculates an inverse volatility score (`alpha`) and a viscosity signal combining volatility changes with spot returns (`alpha9`) to detect periods of low volatility resistance. The strategy generates credit put spreads (sell ATM put, buy ITM put 400 points lower) when both signals are bullish (alpha > 0.75, alpha9 > 0.7), and credit call spreads (sell ATM call, buy OTM call 400 points higher) when signals are bearish (alpha < 0.25, alpha9 < 0.3).
**Risk Management:** Dynamic stop-loss calculation using `(3000 / margin_required) * 100` ensures maximum loss of 3000 rupees per trade. Includes time filters (10:15 AM to 2:15 PM), data freshness checks (within 2 minutes), market open validation, and advisor kill switch monitoring. Uses 100% capital allocation with multi-trade alerts and prevents position overlap by checking for active trades.