DAYTF = tsl.get_historical_data(tradingsymbol = stock_name,exchange = ‘NSE’,timeframe=“1day”)
TODAY_5MIN = tsl.get_historical_data(tradingsymbol = stock_name,exchange = ‘NSE’,timeframe=“5”) # this call has been updated to get_historical_data call,
if (DAYTF is None) or (TODAY_5MIN is None) :
continue
if (DAYTF.empty) or (TODAY_5MIN.empty):
continue
# Conditions to fetch yesterdays data (high and low and close)
yesterday = DAYTF.iloc[-1] #pandas yesterday completed candle
return PDH = yesterday['high'],
return PDL = yesterday['low'],
return PD_open = yesterday['open']
return PD_close = yesterday['close']
# coditions to fetch current day's open
today = DAYTF.iloc[0]
return Today_OPEN = today['open']
#conditions to check gap_up or gap_down and bullish or bearish yesterday's daily candle
gap_up = Today_OPEN > PD_close
gap_down = Today_OPEN < PD_close
yesterday_bullish = PD_close > PD_open
yesterday_bearish = PD_close < PD_open
# Conditions that are on 5 minute timeframe
cc_5 = TODAY_5MIN.iloc[-1] # pandas
prev_cc_5 = TODAY_5MIN.iloc[-2]
third_cc_5 = TODAY_5MIN.iloc[-3]
bullish_reversal = third_cc_5['close'] >= PDL and prev_cc_5['close'] < PDL and cc_5['close'] > PDL
bearish_reversal = third_cc_5['close'] <= PDH and prev_cc_5['close'] > PDH and cc_5['close'] < PDH