Beginner Algo Trading series 2026 | Codes | Youtube

Hi everyone,

We’re grateful for the overwhelming response to our previous algo trading series :raising_hands:
Continuing the same momentum, we’ve now created the 2026 version of the Beginner Algo Trading series.

Below are the code files that were created during Beginner Algo Trading 2026. We’ll keep updating the codes and scripts as new videos are released. You can also use this thread to post any questions or queries related to the videos.

Happy learning and building :rocket:

Algo Trading for Beginners - drive link - here

Python for Algo Trading: Step-by-Step Guide - drive link - here

Momentum scanner Algo - drive link - here

Live Intraday Algo - drive link - here

Option Buying Scalping Algo - drive link - here

1 Like

its possible to trade from python algo without any static IP with Dhan. My service provider dont give static IP for home internet connection so i am unable to connect with all other broker. its possible with Dhan ?

Hi @Sreeraj_PV ,

A static IP is required for trading. As per the latest SEBI guidelines, a static IP must be configured in order to place trades through the API.

Hello Sir,

I am trying to login but it shows wrong totp . i have tried many times but not working.

please help.

sir apna reply nahi diya or ya app bahut confuction ha is ma aap sa bath kaha kara kuch pata nahi chalta .app ka pass kuch dusra msg app ha kya app sa bath karna ka liya .mujhe ake algo bana ha 15 min candel hgh or low pa brake ka badh 5 min candle retest conformation or do pattern hamer or bullish engulfing for buy side or sell side ulta can u do or gide me in nifty only

Can you share the steps to install on a Mac?
AlgoTraderInstaller.exe and CursorSetup-x64-3.5.38.exe
Can’t run these on Mac.

Hi @Dr.Bhavesh_Rathod ,

First, disable the existing TOTP in the settings and create a new one by following the steps below:

Steps to Set Up / Get TOTP Key in Dhan:

  1. Log in to your Dhan web account.
  2. Go to your Profile section and open Get Trading & Data APIs.
  3. Click on “Set-up TOTP” under Optional Settings.
  4. Verify using the OTP sent to your registered email/mobile number and scan the QR code using an authenticator app.
  5. Enter the 6-digit code generated by the authenticator app to complete the setup.

Once the new TOTP has been created, try run it again.

If the issue still persists, share a screenshot so that it can be reviewed further.

Hello sir mujhe guide karo please me python kis episode se sikna suru Karu first part me same code likh ne par bhi errors are hen kya kuchh changes huehen kya or second lecture ka installation expire ho gya he ?

Hi @HASAN_khan ,

Share the error details or a screenshot of the error for further clarification.

1 Like

Hi @Ammar_parihar ,

Refer the pseudocode -

START

ref_15m_high = None
ref_15m_low = None

breakout_side = None
breakout_level = None

waiting_for_retest = False
trade_taken = False

previous_5m_candle = None


ON EVERY NEW 15-MINUTE CANDLE CLOSE:

    ref_15m_high = 15m_candle.high
    ref_15m_low  = 15m_candle.low

    breakout_side = None
    breakout_level = None

    waiting_for_retest = False
    trade_taken = False


ON EVERY TICK / LTP UPDATE:

    IF trade_taken == False AND waiting_for_retest == False:

        IF ltp > ref_15m_high:

            breakout_side = "BUY"
            breakout_level = ref_15m_high
            waiting_for_retest = True


        ELSE IF ltp < ref_15m_low:

            breakout_side = "SELL"
            breakout_level = ref_15m_low
            waiting_for_retest = True


ON EVERY NEW 5-MINUTE CANDLE CLOSE:

    current_5m_candle = latest closed 5m candle

    IF previous_5m_candle is None:

        previous_5m_candle = current_5m_candle
        SKIP


    IF waiting_for_retest == True AND trade_taken == False:


        --------------------------------
        BUY SIDE
        --------------------------------

        IF breakout_side == "BUY":

            retest_confirmed =
                current_5m_candle.low <= breakout_level
                AND current_5m_candle.close > breakout_level

            hammer =
                current_5m_candle has small body
                AND lower wick is at least 2 times body
                AND upper wick is small
                AND candle closes bullish

            bullish_engulfing =
                previous_5m_candle is bearish
                AND current_5m_candle is bullish
                AND current candle body engulfs previous candle body

            IF retest_confirmed == True AND (hammer == True OR bullish_engulfing == True):

                BUY SIGNAL

                entry_price = current_5m_candle.close
                stoploss = current_5m_candle.low

                trade_taken = True
                waiting_for_retest = False


        --------------------------------
        SELL SIDE
        --------------------------------

        ELSE IF breakout_side == "SELL":

            retest_confirmed =
                current_5m_candle.high >= breakout_level
                AND current_5m_candle.close < breakout_level

            shooting_star =
                current_5m_candle has small body
                AND upper wick is at least 2 times body
                AND lower wick is small
                AND candle closes bearish

            bearish_engulfing =
                previous_5m_candle is bullish
                AND current_5m_candle is bearish
                AND current candle body engulfs previous candle body

            IF retest_confirmed == True AND (shooting_star == True OR bearish_engulfing == True):

                SELL SIGNAL

                entry_price = current_5m_candle.close
                stoploss = current_5m_candle.high

                trade_taken = True
                waiting_for_retest = False


    previous_5m_candle = current_5m_candle

image sir i am fasing this issue

Hi @Sunny_Verma1 ,

An active API subscription is required to access the data. Kindly subscribe first and then try again.

I downloaded the latest version (Session 3), but the Dhan_websocket.py file is missing. I tried using data.py instead, but it is not working.

Below are the steps I have completed:

1.install libraries.bat – Installed :white_check_mark:

2.python-3.8.0-amd64.exe – Installed :white_check_mark:

3.sublime_text_build_4152_x64_setup.exe – Installed :white_check_mark:

4.Excel – Enabled :white_check_mark:

5.Latest Version (Session 3) – Downloaded :white_check_mark:

6.Dhan_websocket.py – Missing from Session 3 :cross_mark:

 I tried using data.py, but it is not working.

7.data.py

 client_code – Updated ✅
 token_id – Updated ✅

8. Dhan_codebase usage.py

 client_code – Updated ✅
token_id – I couldn’t find any place to paste the token_id. Is there a specific line or option where it should be added?

9. Dhan_Tradehull.py

client_code – I couldn’t find any place to paste the client_code.
token_id – I couldn’t find any place to paste the token_id.
  1. Dhan Data API Monthly Plan (₹499/month) – Purchased :white_check_mark:

1 Ran the command:

 pip install dhanhq==2.2.0

but it shows some errors.

Issue- Excel data is not updating. :cross_mark:

Issue- Excel is not opening. :cross_mark:

Could you please check the attached screenshots and help me identify what is causing these issues? I would appreciate your guidance on how to fix them.

Screenshot 2026-07-03 191126

Hi @Nibu ,

Do the following steps to resolve the installation error. Once the installation issue is resolved, everything should work as expected.

Step 1: Check Python version

python --version

Step 2: Check pip version

python -m pip --version

Step 3: Upgrade pip

python -m ensurepip --upgrade

Step 4: Upgrade required packages

python -m pip install --upgrade pip setuptools wheel certifi

Step 5: Install DhanHQ

python -m pip install dhanhq==2.2.0

Step 6: If the SSL error still comes, use this command

python -m pip install dhanhq==2.2.0 --trusted-host pypi.org --trusted-host files.pythonhosted.org