# =========================================
# 1. STRIKE SELECTION
# =========================================
def select_strikes(candle_close):
strike_gap = 50
ce_strike = candle_close + (3 * strike_gap)
pe_strike = candle_close - (3 * strike_gap)
return ce_strike, pe_strike
# =========================================
# 2. SMA3 HIGH CALCULATION
# =========================================
def calculate_sma3_high(previous_day_candles):
high_values = []
for candle in previous_day_candles:
high_values.append(candle["high"])
sma3_high = sum(high_values) / len(high_values)
return sma3_high
# =========================================
# 3. BREAKOUT CHECK
# =========================================
def check_breakout(current_candle, sma3_high):
if (
current_candle["open"] > sma3_high
and
current_candle["close"] > sma3_high
):
return True
return False
# =========================================
# 4. TRADE DETAILS
# =========================================
def create_trade(entry_price):
stop_loss = entry_price - 7
target = entry_price + (entry_price * 1 / 2)
return stop_loss, target
# =========================================
# 5. TODAY'S 5-MINUTE CANDLE CLOSE
# =========================================
candle_close = 25200
# =========================================
# 6. SELECT 3 OTM STRIKES
# =========================================
ce_strike, pe_strike = select_strikes(candle_close)
print("CE Strike:", ce_strike)
print("PE Strike:", pe_strike)
# =========================================
# 7. PREVIOUS DAY SELECTED CE PREMIUM DATA
# =========================================
ce_previous_day = [
{"open": 170, "high": 180, "low": 165, "close": 175},
{"open": 190, "high": 200, "low": 185, "close": 195},
{"open": 210, "high": 220, "low": 205, "close": 215}
]
# =========================================
# 8. PREVIOUS DAY SELECTED PE PREMIUM DATA
# =========================================
pe_previous_day = [
{"open": 150, "high": 160, "low": 145, "close": 155},
{"open": 160, "high": 170, "low": 155, "close": 165},
{"open": 170, "high": 180, "low": 165, "close": 175}
# =========================================
# 9. CALCULATE SMA3 HIGH
# =========================================
ce_sma3_high = calculate_sma3_high(ce_previous_day)
pe_sma3_high = calculate_sma3_high(pe_previous_day)
print("CE SMA3 High:", ce_sma3_high)
print("PE SMA3 High:", pe_sma3_high)
# =========================================
# 10. CURRENT PREMIUM CANDLE
# =========================================
ce_current_candle = {
"open": 230,
"high": 240,
"low": 225,
"close": 235
pe_current_candle = {
"open": 190,
"high": 200,
"low": 185,
"close": 195
# =========================================
# 11. TRADE STATUS
# =========================================
ce_trade_done = False
pe_trade_done = False
ce_trade_active = False
pe_trade_active = False
# =========================================
# 12. CE ENTRY
# =========================================
ce_breakout = check_breakout(
ce_current_candle,
ce_sma3_high
if ce_breakout and ce_trade_done == False:
ce_entry = ce_current_candle["close"]
ce_stop_loss, ce_target = create_trade(ce_entry)
ce_trade_done = True
ce_trade_active = True
print("BUY CE")
print("CE Entry:", ce_entry)
print("CE Stop Loss:", ce_stop_loss)
print("CE Target:", ce_target)
# =========================================
# 13. PE ENTRY
# =========================================
pe_breakout = check_breakout(
pe_current_candle,
pe_sma3_high
if pe_breakout and pe_trade_done == False:
pe_entry = pe_current_candle["close"]
pe_stop_loss, pe_target = create_trade(pe_entry)
pe_trade_done = True
pe_trade_active = True
print("BUY PE")
print("PE Entry:", pe_entry)
print("PE Stop Loss:", pe_stop_loss)
print("PE Target:", pe_target)
# =========================================
# 14. EXIT MONITORING
# =========================================
while ce_trade_active or pe_trade_active:
# Practice live premium data
ce_current_premium = 250
pe_current_premium = 210
# -------------------------
# CE EXIT
# -------------------------
if ce_trade_active:
if ce_current_premium <= ce_stop_loss:
print("CE STOP LOSS HIT")
ce_trade_active = False
elif ce_current_premium >= ce_target:
print("CE TARGET HIT")
ce_trade_active = False
# -------------------------
# PE EXIT
# -------------------------
if pe_trade_active:
if pe_current_premium <= pe_stop_loss:
print("PE STOP LOSS HIT")
pe_trade_active = False