This algorithm implements a credit spread strategy using Geometric Brownian Motion (GBM) scoring to identify range-bound market conditions. It calculates a GBM score measuring the probability of price movement within OTM and ITM strike boundaries, combined with IV skew ratios and volume dynamics. The strategy generates credit put spreads (sell ATM put, buy ITM put 400 points lower) when both alpha signals are bullish, and credit call spreads (sell ATM call, buy OTM call 400 points higher) when signals are bearish.
Risk Management: The algorithm employs dynamic stop-loss calculation based on margin requirements - the stop-loss percentage is calculated as (3000 / margin_required) * 100, ensuring a maximum loss of 3000 rupees per trade regardless of position size. It includes time-based filters (10:15 AM to 2:15 PM trading window), data freshness checks (within 2 minutes of data save), market open status validation, and advisor kill switch monitoring. The strategy uses 100% capital allocation with multi-trade alerts and only executes when no active trades are running, preventing position overlap and ensuring proper risk control.