• Products
    Investment Suite
    Stocks
    Mutual Funds
    Future and Options
    IPO
    Exchange Traded Funds
    Commodity
    Stockcase (Stock Baskets)
    Non Convertible Debentures
    Sovereign Gold Bond
    Exclusive
    NRI Account
    Corporate/HUF Trading Account
    Private Client Group
    Features
    SipIt
    MTF
    Investment Suite
    Exclusive
    Features
    Stocks
    Mutual Funds
    Future and Options
    IPO
    Exchange Traded Funds
    Commodity
    Stockcase (Stock Baskets)
    Non Convertible Debentures
    Sovereign Gold Bond
    NRI Account
    Corporate/HUF Trading Account
    Private Client Group
    SipIt
    MTF
  • Platform
    Trading Platforms
    Kotak Neo App & Web
    Nest Trading Terminal
    NEO Trade APIs
    Trade From Charts
    Features and Tools
    MTF
    Securities Accepted as Collateral
    Margin Requirements
    Equity Screeners
    Payoff Analyzer
    Calculators
    SIP Calculator
    Lumpsum Calculator
    Brokerage Calculator
    Margin Calculator
    MTF Calculator
    SWP Calculator
    CAGR Calculator
    Simple Interest Calculator
    ELSS Calculator
    Step up SIP Calculator
    All Calculators
    Trading Platforms
    Features and Tools
    Calculators
    Kotak Neo App & Web
    Nest Trading Terminal
    NEO Trade APIs
    Trade From Charts
    MTF
    Securities Accepted as Collateral
    Margin Requirements
    Equity Screeners
    Payoff Analyzer
    SIP Calculator
    Lumpsum Calculator
    Brokerage Calculator
    Margin Calculator
    MTF Calculator
    SWP Calculator
    CAGR Calculator
    Simple Interest Calculator
    ELSS Calculator
    Step up SIP Calculator
  • Pricing
  • Research
    Research Calls
    Long Term calls
    Short Term calls
    Intraday calls
    Derivatives calls
    Pick of the week
    Top Monthly Picks
    Stock Research Recommendations
    MTF Stock Recommendations
    Research Reports
    Fundamental Research Report
    Technical Research Report
    Derivative Research Report
    Commodities Research Report
    Research Calls
    Research Reports
    Long Term calls
    Short Term calls
    Intraday calls
    Derivatives calls
    Pick of the week
    Top Monthly Picks
    Stock Research Recommendations
    MTF Stock Recommendations
    Fundamental Research Report
    Technical Research Report
    Derivative Research Report
    Commodities Research Report
  • Market
    Market Movers
    Share Market Today
    Top Gainers
    Top Losers
    Stocks
    Large Cap
    Mid Cap
    Small Cap
    Indices
    Nifty 50
    Nifty Bank
    FinNifty
    Nifty Midcap India
    India VIX
    All Indices
    Mutual Funds
    SBI Mutual Funds
    HDFC Mutual Funds
    Axis Mutual Funds
    ICICI Prudential Mutual Funds
    Nippon India Mutual Funds
    All AMC's
    IPO
    Upcoming IPO
    Current IPO
    IPO Allotment Status
    IPO Subscription Status
    Closed IPO
    Recently Listed IPO
    Quarterly Results
    Australian Premium Solar (India)'s Q2 FY 2025-26 Quarterly Results
    SG Mart's Q2 FY 2025-26 Quarterly Results
    Rajoo Engineers' Q2 FY 2025-26 Quarterly Results
    Hybrid Financial Services' Q2 FY 2025-26 Quarterly Results
    Market Movers
    Stocks
    Indices
    Mutual Funds
    IPO
    Quarterly Results
    Share Market Today
    Top Gainers
    Top Losers
    52 Week High
    52 Week Low
    Volume Shockers
    Large Cap
    Mid Cap
    Small Cap
    State Bank of India
    Reliance Industries Ltd
    HDFC Bank Ltd
    Infosys Ltd
    Tata Capital
    LG Electronics India
    Tata Consultancy Services Ltd
    Hindustan Unilever Ltd
    ITC Ltd
    IRCTC
    NSE
    Nifty 50
    Nifty Bank
    FinNifty
    Nifty Midcap India
    India VIX
    BSE
    Sensex
    BSE Bankex
    BSE Small Cap
    BSE Mid Cap
    BSE 100
    Global Indices
    Gift Nifty
    Dow Jones
    Nikkei Index
    Hong Kong Index
    KOSPI Index
    AMC's
    SBI Mutual Funds
    HDFC Mutual Funds
    Axis Mutual Funds
    ICICI Prudential Mutual Funds
    Nippon India Mutual Funds
    Schemes
    Parag Parikh Flexi Cap
    SBI Small Cap Fund
    SBI Contra Fund
    Nippon Small Cap Fund
    ICICI Pru Technology Fund
    NFO
    Upcoming IPO
    Current IPO
    IPO Allotment Status
    IPO Subscription Status
    Closed IPO
    Recently Listed IPO
    Safecure Services IPO
    Orkla India IPO
    Studds IPO
    Lenskart IPO
    Curis Lifesciences IPO
    Finbud Financial Services IPO
    Shreeji Global FMCG IPO
    Groww IPO
    Australian Premium Solar (India)'s Q2 FY 2025-26 Quarterly Results
    SG Mart's Q2 FY 2025-26 Quarterly Results
    Rajoo Engineers' Q2 FY 2025-26 Quarterly Results
    Hybrid Financial Services' Q2 FY 2025-26 Quarterly Results
    Inventurus Knowledge Solutions' Q2 FY 2025-26 Quarterly Results
    Onelife Capital Advisors' Q2 FY 2025-26 Quarterly Results
    Jet Freight Logistics' Q2 FY 2025-26 Quarterly Results
    Xchanging Solutions' Q2 FY 2025-26 Quarterly Results
    Welspun Corp's Q2 FY 2025-26 Quarterly Results
    United Spirits' Q2 FY 2025-26 Quarterly Results
    Union Bank of India's Q2 FY 2025-26 Quarterly Results
    TD Power Systems' Q2 FY 2025-26 Quarterly Results
  • Learn
    Stockshaala
    Basics of Stock Market
    Introduction to Fundamental Analysis
    Introduction to Technical Analysis
    Derivatives, Risk management & Option Trading Strategies
    Personal Finance
    Explore More
    Resource
    Market Ready
    Kotak Insights
    Infographic
    Podcast
    Webinars
    Youtube Channel
    Investing Guide
    Demat Account
    Trading Account
    Share Market
    Intraday Trading
    IPO
    Mutual Funds
    Events
    Budget 2025
    Muhurat Trading
    Share Market Holiday
    Market Outlook 2025
    Stockshaala
    Resource
    Investing Guide
    Events
    Basics of Stock Market
    Introduction to Fundamental Analysis
    Introduction to Technical Analysis
    Derivatives, Risk management & Option Trading Strategies
    Personal Finance
    Market Ready
    Kotak Insights
    Infographic
    Podcast
    Webinars
    Youtube Channel
    Demat Account
    Trading Account
    Share Market
    Intraday Trading
    IPO
    Mutual Funds
    Budget 2025
    Muhurat Trading
    Share Market Holiday
    Market Outlook 2025
  • Partner
    Business Associates
    Kotak Connect Plus
    Startup connect
    Business Associates
    Kotak Connect Plus
    Startup connect
  • Support
    FAQs
    Circulars
    Bulletins
    Contact Us
    Forms Download
    Get your Statement
    FAQs
    Circulars
    Bulletins
    Contact Us
    Forms Download
    Get your Statement
  • News

logo
Algorithmic Trading
6 Modules | 23 Chapters
Module 5
Popular Algo Trading Strategies
Course Index

Algo Strategy: Mean Reversion – Buy the Dip, Sell the Spike

You’ve heard it before:

“Buy low, sell high.” “Stocks always return to their average.”

That’s the philosophy behind mean reversion.

When a stock moves too far from its usual price range, algo traders assume it’ll come back (or "revert") to the mean (average). So they buy the dip or sell the spike.

Imagine a stock usually trades between ₹90 and ₹110.

One day, due to panic, it drops to ₹80.

A mean reversion algo will buy at ₹80, expecting it to bounce back toward ₹100.

It assumes the price move was an overreaction — not a new trend.

Indicators to detect mean reversion opportunities:

  • Bollinger Bands
    These bands expand and contract based on volatility.
    If price touches the lower band, it may be oversold – a buy signal.
    If it touches the upper band, it may be overbought – a sell signal.

import pandas as pd

def calculate_bollinger_bands(data, window=20, num_std=2): """ Calculate Bollinger Bands.

Parameters:
    data    : DataFrame with 'close' prices
    window  : Moving average period
    num_std : Number of standard deviations

Returns:
    DataFrame with columns: MA, Upper Band, Lower Band
"""
data['MA'] = data['close'].rolling(window=window).mean()
data['STD'] = data['close'].rolling(window=window).std()
data['Upper'] = data['MA'] + (data['STD'] * num_std)
data['Lower'] = data['MA'] - (data['STD'] * num_std)
return data[['MA', 'Upper', 'Lower']]

#Example usage: #df = calculate_bollinger_bands(price_data)

  • RSI (Relative Strength Index)

RSI < 30 = Oversold (Buy)
RSI > 70 = Overbought (Sell)

def calculate_rsi(data, period=14): """ Calculate Relative Strength Index (RSI).

Parameters:
    data   : DataFrame with 'close' prices
    period : Lookback period (default = 14 days)

Returns:
    Series containing RSI values
"""
delta = data['close'].diff()  # Price changes

#Separate gains and losses
gain = delta.where(delta > 0, 0)
loss = -delta.where(delta < 0, 0)

#Use Exponential Moving Average (smoother than simple average)
avg_gain = gain.ewm(span=period, adjust=False).mean()
avg_loss = loss.ewm(span=period, adjust=False).mean()

#Relative Strength (RS)
rs = avg_gain / avg_loss

#RSI Formula
rsi = 100 - (100 / (1 + rs))
return rsi
  • Moving Average Pullbacks

If price falls 5-10% below its moving average, the algo might trigger a buy.

Let’s say:

  • Stock's 20-day moving average = ₹100
  • Current price = ₹88
  • RSI = 25

Your algo says, “This is too cheap!”
It buys the stock and exits when price hits ₹98 or RSI crosses 50.

import pandas as pd

def calculate_moving_average(data, window=20): """ Calculate Simple Moving Average (SMA).

Parameters:
    data   : DataFrame with a 'close' column
    window : Lookback period (default = 20)

Returns:
    Series with SMA values
"""
return data['close'].rolling(window=window).mean()

#Example usage: #price_data['SMA_20'] = calculate_moving_average(price_data, window=20)

  • Markets overreact to news, panic, or short-term hype
  • Prices tend to return to fair value
  • It works well in sideways or range-bound markets
  • Trending markets can kill this strategy – the stock may keep falling!
  • Never assume a dip = reversal. Always use:
  • Stoploss
  • Position sizing
  • Time-based exit (e.g., exit if no reversal in 3 days)
  • Combine multiple indicators (e.g., RSI + Bollinger)
  • Avoid trading during news events (like RBI policy or earnings)
  • Limit exposure to a few trades at a time

So, momentum = ride the wave
Mean reversion = catch the bounce

Both have their place. Algos help you remove emotion and follow logic.

Next up: A very interesting concept – Pairs Trading, where you don’t care about market direction at all!

Is this chapter helpful?
Share
What could we have done to make this article better?

Algo Strategy: Momentum Strategy - Ride the wave
Algo Strategy: Pairs Trading – Neutral & Smart

Disclaimer: This article is for informational purposes only and does not constitute financial advice. It is not produced by the desk of the Kotak Securities Research Team, nor is it a report published by the Kotak Securities Research Team. The information presented is compiled from several secondary sources available on the internet and may change over time. Investors should conduct their own research and consult with financial professionals before making any investment decisions. Read the full disclaimer here.

Investments in securities market are subject to market risks, read all the related documents carefully before investing. Brokerage will not exceed SEBI prescribed limit. The securities are quoted as an example and not as a recommendation. SEBI Registration No-INZ000200137 Member Id NSE-08081; BSE-673; MSE-1024, MCX-56285, NCDEX-1262.

Algo Strategy: Momentum Strategy - Ride the wave
Algo Strategy: Pairs Trading – Neutral & Smart

Disclaimer: This article is for informational purposes only and does not constitute financial advice. It is not produced by the desk of the Kotak Securities Research Team, nor is it a report published by the Kotak Securities Research Team. The information presented is compiled from several secondary sources available on the internet and may change over time. Investors should conduct their own research and consult with financial professionals before making any investment decisions. Read the full disclaimer here.

Investments in securities market are subject to market risks, read all the related documents carefully before investing. Brokerage will not exceed SEBI prescribed limit. The securities are quoted as an example and not as a recommendation. SEBI Registration No-INZ000200137 Member Id NSE-08081; BSE-673; MSE-1024, MCX-56285, NCDEX-1262.

Beyond Stockshaala

Discover our extensive knowledge center

Kotak Insights

An insightful weekend read on market trends, company stories, and historical events.

Neo Shorts

A visual spotlight on buzzing sectors and rising stars of the Indian stock market.

Investing Guide

Comprehensive library of blogs focussed to build your financial confidence.

Market Ready

Stay ahead of the game with daily market trends, global insights, and key investment updates.

Webinars

Live sessions with industry leaders for in-depth market knowledge.

Podcast

Latest trends, strategies, and market updates with our seasoned experts.