Algo Trading
Bottom-Out-Hunting (BOH): A Simple Yet Powerful Filter for Swing Trades

FabTrader
In trading, some of the best opportunities often emerge when stocks start recovering from their lows — when pessimism fades and buying strength quietly returns. This concept forms the foundation of what is popularly referred to as Bottom-Out-Hunting (BOH) — a simple yet powerful filter that can help swing traders identify potential recovery candidates early in their up-move.
Let’s break it down.
The Core Idea
Every stock experiences highs and lows over time. The 52-week high and 52-week low are among the most commonly tracked price points in technical analysis.
Now imagine this:
- A stock made its 52-week high a few months ago.
- Then, due to selling pressure or a broader market correction, it touched its 52-week low more recently.
- And now, it’s starting to recover from that low.
This is where the BOH filter comes into play.
If the date of the 52-week low is more recent than the date of the 52-week high, it means the stock has already undergone a correction phase and might be in the early stages of recovery. When such a stock belongs to a healthy, liquid universe, it often becomes a great candidate for swing or positional trades on the long side.
On the flip side, if the stock’s 52-week high is the more recent event, it might still be near its top or entering a correction phase — not the ideal time to look for fresh long trades.
In short:
BOH Filter = True → Stock has recently bottomed out and is recovering.
BOH Filter = False → Stock might be topping out or consolidating.
Why It Works
Traders often chase momentum or breakout trades. But sometimes, the best opportunities lie in recovery setups — when the crowd has given up, volumes dry out, and quietly, the trend begins to reverse.
BOH acts as a pre-filter — helping you shortlist stocks that may be starting their uptrend after hitting their 52-week lows. You can then combine this with other filters like volume confirmation, moving averages, or RSI divergence for better precision.
The Python Code
Here’s a simple Python function that automates this logic using Yahoo Finance data. It takes a stock ticker as input and returns whether the BOH condition is met or not.
# ------------------------------------------------------------------------------------
# FabTrader Algo Trading Academy
# ------------------------------------------------------------------------------------
# Copyright (c) 2025 FabTrader
# CONTACT:
# - Website: https://fabtrader.in
# - Email: [email protected]
# Usage: Personal use only. Not for commercial redistribution.
# Permissions and licensing inquiries should be directed to the contact email.
"""
Bottom-Out-Hunting (BOH) Filter
-------------------------------
Author: FabTrader
Website: https://fabtrader.in
Description:
-------------
This script implements the Bottom-Out-Hunting (BOH) filter — a simple yet effective idea
used by swing and algo traders to identify potential recovery stocks.
The logic is straightforward:
- If the stock's 52-week LOW occurred more recently than its 52-week HIGH,
it indicates the stock might have bottomed out and could be in a recovery phase.
- If the 52-week HIGH is more recent, the stock may still be in a downward or topping phase.
The program fetches 1 year of daily price data from Yahoo Finance and evaluates
whether the BOH condition is True or False for any given stock ticker.
Usage:
------
1. Install dependencies:
pip install yfinance
2. Run the script after inputting in a stock short code
"""
import yfinance as yf
from datetime import datetime, timedelta
def bottom_out_hunting(ticker: str):
"""
Determines if a stock meets the Bottom-Out-Hunting (BOH) condition.
Condition:
True if the stock's 52-week low is more recent than its 52-week high.
False otherwise.
Args:
ticker (str): Stock ticker symbol (e.g., "RELIANCE.NS", "AAPL")
Returns:
dict: {
'Ticker': str,
'52_Week_High': float,
'52_Week_High_Date': str,
'52_Week_Low': float,
'52_Week_Low_Date': str,
'BOH_Filter': bool
}
"""
# Fetch 1 year (52 weeks) of daily data
end_date = datetime.today()
start_date = end_date - timedelta(weeks=52)
try:
data = yf.download(
ticker + '.NS', start=start_date, end=end_date,
progress=False, auto_adjust=True,
multi_level_index=False
)
if data.empty:
return {"Error": f"No data found for {ticker}"}
# Calculate 52-week high and low
high_price = data['High'].max()
low_price = data['Low'].min()
# Get corresponding dates
high_date = data['High'].idxmax().date()
low_date = data['Low'].idxmin().date()
# Apply the BOH logic
boh_filter = low_date > high_date
return {
'Ticker': ticker,
'52_Week_High': round(high_price, 2),
'52_Week_High_Date': str(high_date),
'52_Week_Low': round(low_price, 2),
'52_Week_Low_Date': str(low_date),
'BOH_Filter': boh_filter
}
except Exception as e:
print("Error : Data extract failed. Error :", e)
return None
if __name__ == "__main__":
ticker = "INFY"
result = bottom_out_hunting(ticker)
if result is not None:
print("***** Bottom Out Hunting (BOH) Filter *****")
print("Ticker : ", result['Ticker'])
print("52 Week High : ", result['52_Week_High'])
print("52 Week High Date : ", result['52_Week_High_Date'])
print("52 Week Low : ", result['52_Week_Low'])
print("52 Week Low Date : ", result['52_Week_Low_Date'])
print("BOH Filter Flag : ", result['BOH_Filter'])
if result['BOH_Filter']:
print("Filter Verdict : Suitable for a swing trade")
else:
print("Filter Verdict : Not Suitable for a swing trade")Sample Output:
***** Bottom Out Hunting (BOH) Filter *****
Ticker : INFY
52 Week High : 1978.61
52 Week High Date : 2024-12-13
52 Week Low : 1288.87
52 Week Low Date : 2025-04-07
BOH Filter Flag : True
Filter Verdict : Suitable for a swing trade
Process finished with exit code 0Wrapping Up
This small utility may look simple, but it’s an excellent addition to your algo trading toolkit. You can integrate it into your broader stock selection or swing trading framework — maybe as one of the filters before a setup is triggered.
Trading isn’t about complexity. It’s about building small, smart edges that stack up over time. The BOH filter is exactly that — a tiny edge that helps you spot recoveries early.
Try it out, tweak it, and make it your own.
More from Algo Trading
Algo Trading Cost in India: How I Built a Reliable Setup for ₹150/Month
Wondering how much algo trading costs in India? In this article, I break down the real expenses involved in running an algorithmic...
When Your Job Feels Shaky: Can Trading Become an Alternate Income Stream?
Can trading become a stable source of income in India? While many consider it during times of job uncertainty, the reality is...
How Much Capital Do You Really Need for Sustainable Trading Income in India?
How much capital is needed for sustainable trading income in India? This in-depth guide explores the realistic returns traders can expect, the...
