0% found this document useful (0 votes)
0 views7 pages

code2

The document outlines a trading strategy involving strike selection, SMA3 high calculation, and breakout checks for options trading. It includes functions for selecting strikes based on candle close, calculating the simple moving average of high values, and determining trade details like stop loss and target. The main program executes these functions using predefined candle data to assess potential trades for call and put options.

Uploaded by

riskreward102
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views7 pages

code2

The document outlines a trading strategy involving strike selection, SMA3 high calculation, and breakout checks for options trading. It includes functions for selecting strikes based on candle close, calculating the simple moving average of high values, and determining trade details like stop loss and target. The main program executes these functions using predefined candle data to assess potential trades for call and put options.

Uploaded by

riskreward102
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

# =========================================

# 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

else:

return False

# =========================================

# 4. TRADE DETAILS

# =========================================

def create_trade(entry):

stop_loss = entry - 7

target = entry + (entry * 1 / 2)


return stop_loss, target

# =========================================

# 5. MAIN PROGRAM

# =========================================

# 5-minute candle close

candle_close = 25200

# Strike selection

ce_strike, pe_strike = select_strikes(candle_close)

print("CE Strike:", ce_strike)

print("PE Strike:", pe_strike)

# =========================================

# PREVIOUS DAY 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}

]
# =========================================

# PREVIOUS DAY 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}

# 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)

# =========================================

# TODAY'S CURRENT PREMIUM CANDLES

# =========================================

ce_current_candle = {
"open": 230,

"high": 240,

"low": 225,

"close": 235

pe_current_candle = {

"open": 190,

"high": 200,

"low": 185,

"close": 195

# =========================================

# TRADE STATUS

# =========================================

ce_trade_done = False

pe_trade_done = False

# =========================================

# 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

print("BUY CE")

print("CE Entry:", ce_entry)

print("CE Stop Loss:", ce_stop_loss)

print("CE Target:", ce_target)

# =========================================

# 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

print("BUY PE")

print("PE Entry:", pe_entry)

print("PE Stop Loss:", pe_stop_loss)

print("PE Target:", pe_target)

You might also like