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
Hi @NiKHiL_S_R
there is corrected needed in
DAYTF = tsl.get_historical_data(tradingsymbol='ACC', exchange='NSE', timeframe="DAY")
also do share the questions on below link, related to algo trading series
https://private-poc.madefortrade.in/t/learn-algo-trading-with-python-codes-youtube-series/32718/1426
Vidur
July 16, 2026, 8:53am
3
Same difficulty i am facing.
i have logic and made some improvement but since i am not a python coder, i am facing challenges in executing it smoothly. I use dhan cloud. @Tradehull_Imran Please help.
for intraday only-
i am using 1min,3min,5min candle with bb,rsi,ema.
if certain condtion met, trade should initiate.
exit based on 3min ema9_smooth9 or target reach or trail stop loss.
Kindly let me know your available time to connect with you.
Hi @Vidur ,
Refer the pseudocode -
# Intraday strategy pseudocode
while market_is_open:
get_1min_3min_5min_candles()
calculate_BB_RSI_EMA()
if no_open_position:
if buy_condition_met:
enter_buy()
set_target()
set_trailing_stop()
elif sell_condition_met:
enter_sell()
set_target()
set_trailing_stop()
else:
update_trailing_stop()
if target_reached:
exit_trade("TARGET")
elif trailing_stop_hit:
exit_trade("TRAIL STOP")
elif three_min_ema9_crosses_ema9_smooth9:
exit_trade("EMA EXIT")
if force_exit_time_reached:
exit_open_trade()
stop_strategy()
1 Like
Vidur
July 18, 2026, 7:55am
5
thank you very much imran sir
1 Like
Vidur
July 20, 2026, 8:24am
6
2026-07-20 13:49:37 IST] ==================== SCRIPT OUTPUT START ====================
› [2026-07-20 13:49:39 IST] =======================================
› [2026-07-20 13:49:39 IST] NIFTY Triple Chart Algo Started
› [2026-07-20 13:49:39 IST] DhanHQ Version : 2.2.0
› [2026-07-20 13:49:39 IST] Order Type : MARKET
› [2026-07-20 13:49:39 IST] Lot Size : 65
› [2026-07-20 13:49:39 IST] =======================================
› [2026-07-20 13:49:39 IST] [API_INIT] → Dhan Client structural handler built successfully.
› [2026-07-20 13:49:39 IST] ==================== SCRIPT OUTPUT END ====================
› [2026-07-20 13:49:39 IST] Execution completed successfully
i am getting this error. System is not executing any further. I have placed tags as well. Can i share my full code here for you to verify ?
Hi @Vidur ,
Market orders cannot be placed through the API due to the latest SEBI guidelines. Change the order type and check once.