Option trading strategy with VWAP and EMA

@Tradehull_Imran Hello sir, Need you thoughts on this.

Strategy

Uptrend : 
	Time frame 5 mins
	Price is above VWAP
	Price is above 20 EMA 
	RSI is equal to or grater than 60
	
	
Downtrend
	Time frame 5 mins
	Price is blow VWAP
	Price is below 20 EMA 
	RSI is equal to or less than 40
	
Buy condition 
	If all the above condition met and price reject from 20 EMA buy

Load your data into a DataFrame

Ensure your DataFrame has columns: [‘timestamp’, ‘open’, ‘high’, ‘low’, ‘close’, ‘volume’]

df = pd.read_csv(‘your_data.csv’, parse_dates=[‘timestamp’])

Calculate indicators

df[‘VWAP’] = ta.volume.volume_weighted_average_price(df[‘high’], df[‘low’], df[‘close’], df[‘volume’])
df[‘EMA20’] = ta.trend.ema_indicator(df[‘close’], window=20)
df[‘RSI’] = ta.momentum.rsi(df[‘close’], window=14)

Define conditions

uptrend = (df[‘close’] > df[‘VWAP’]) & (df[‘close’] > df[‘EMA20’]) & (df[‘RSI’] >= 60)
downtrend = (df[‘close’] < df[‘VWAP’]) & (df[‘close’] < df[‘EMA20’]) & (df[‘RSI’] <= 40)

Implement buy conditions for Call (CE) and Put (PE) options

df[‘Buy_CE’] = uptrend & (df[‘low’] < df[‘EMA20’]) & (df[‘close’] > df[‘EMA20’])
df[‘Buy_PE’] = downtrend & (df[‘high’] > df[‘EMA20’]) & (df[‘close’] < df[‘EMA20’])

Results

print(“Call Buy Signals (CE):”)
print(df[df[‘Buy_CE’]])

print(“\nPut Buy Signals (PE):”)
print(df[df[‘Buy_PE’]])

1 Like

Example

Hi @Altaf_Sheikh

Primary code seems to be okey, however you also need to use below code to fetch chart data

chart_5 = tsl.get_historical_data(tradingsymbol = script_name, exchange = 'NSE',timeframe="5")

Also do post your question on below thread

1 Like

Also RSI EMA AND WVAP Algo is already build
see :

1 Like