Algo Trading
Reverse Gear Trading Strategy: Catching Late-Day Reversals

FabTrader
When markets trend strongly in one direction throughout the day, they often experience a late-afternoon reversal that can be both swift and profitable. I've been developing a strategy called "Reverse Gear" that specifically targets these end-of-day reversals, and I'd like to share it with you today.
After testing this approach for several months, I've found it particularly effective during sessions where stocks maintain consistent directional momentum for most of the day before running out of steam in the afternoon. This mean-reversion strategy provides clear entry and exit points with a favorable risk-reward ratio.
The Core Concept
The Reverse Gear strategy is based on a simple premise: what goes up (or down) too far, too fast, tends to reverse. More specifically, when a stock has been trending strongly in one direction and consistently respecting the 20-period EMA as either support or resistance, a breakthrough of this key level in the afternoon often signals a meaningful reversal opportunity.
This strategy works on the 5-minute timeframe and can be applied to both individual stocks and market indices. It can be traded using either cash or options (though I recommend cash for individual stocks unless you're comfortable with the additional risk).
Trading Rules
For Long Entries (When Markets Have Been Trending Down)
- The stock should be in a clear downtrend throughout the day, with a 20 EMA slope below -0.5
- Price action should remain below the 20 EMA for at least 85% of the trading day
- Entry trigger occurs when a 5-minute candle closes above the 20 EMA between 1:45 PM and 2:30 PM
- Place your stop loss at the low of the entry candle
- Take profit at either 0.5% gain or at a 1:2 risk-reward ratio (with trailing stops)
For Short Entries (When Markets Have Been Trending Up)
- The stock should be in a clear uptrend throughout the day, with a 20 EMA slope above 0.5
- Price action should remain above the 20 EMA for at least 85% of the trading day
- Entry trigger occurs when a 5-minute candle closes below the 20 EMA between 1:45 PM and 2:30 PM
- Place your stop loss at the high of the entry candle
- Take profit at either 0.5% gain or at a 1:2 risk-reward ratio (with trailing stops)
Why This Strategy Works
The Reverse Gear strategy capitalizes on several market dynamics:
- Market Exhaustion: Strong trends often exhaust themselves by the afternoon
- Profit Taking: Traders who caught the morning trend frequently close positions before the day's end
- Institutional Rebalancing: Larger players often adjust positions in the afternoon
- Mean Reversion: Markets naturally tend to return to their average price over time
What I love about this strategy is that it provides very clear entry and exit parameters. There's minimal subjectivity - either the conditions are met, or they aren't.
Python Screener Implementation
To systematically apply this strategy, I've developed a Python screener that identifies potential Reverse Gear setups across hundreds of stocks. Here's a simplified version of how it works:
"""
Strategy: Reverse Gear
- On a day when the stock/index is trending, and the candles are mostly above or below 20EMA,
after 2pm when a candle closes on the other side of 20EMA, entry is triggered. This reversal is usually
swift. The SL is the low of the candle that breaks out of the 20EMA.
Type : Trend Reversal
Intraday / CNC : Intraday
Direction : Long & Short
Timeframe: 5 mins
Indicator : 20EMA, Slope
Entry : After 2pm IST
Exit : On the same day by 3 - 3:15pm IST
"""
import yfinance as yf
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from datetime import date, timedelta
# Function to calculate the slope of the closing price trend
def calculate_slope(df):
try:
# Ensure there are enough data points
if df.empty:
return None # Skip stocks with insufficient data
# Prepare data for linear regression (last `window` days)
window = len(df)
X = np.arange(window).reshape(-1, 1) # Days as independent variable
y = df['Close'].iloc[-window:].values.reshape(-1, 1) # Closing prices
# Fit linear regression model
model = LinearRegression().fit(X, y)
slope = model.coef_[0][0] # Extract slope
return slope
except Exception as e:
print(f"Error processing {stock}: {e}")
return None
def check_eligibility(stock):
cols = ['Close','High','Low','Open','Volume','EMA_20']
merged_df = pd.DataFrame()
# begin = date.today() - timedelta(days=4)
begin = date.today()
for i in range(7):
start_date = begin - timedelta(days=i)
end_date = start_date + timedelta(days=1)
start = start_date.strftime('%Y-%m-%d')
end = end_date.strftime('%Y-%m-%d')
df = yf.download(stock, start=start, end=end, interval="5m", progress=False)
if df.empty:
continue
merged_df = pd.concat([merged_df, df], ignore_index=False)
if merged_df.empty:
return None
merged_df = merged_df.tz_convert('Asia/Kolkata')
merged_df.sort_index(inplace=True)
merged_df['EMA_20'] = merged_df['Close'].ewm(span=20, adjust=False).mean()
result_df = merged_df[merged_df.index.date == begin]
result_df = result_df[result_df.index.time <= pd.Timestamp('14:00:00').time()]
result_df = result_df.dropna()
slope = calculate_slope(result_df)
# print(stock, slope)
result_df.columns = cols
print(slope)
if slope >= 0.5:
# Up Trend
result_df['Signal'] = (result_df['Close'] > result_df['EMA_20']).astype(int)
above_the_line = (result_df['Signal'] == 1).mean() * 100
if above_the_line > 85:
return "Short"
elif slope <= -0.5:
# Down Trand
result_df['Signal'] = (result_df['Close'] < result_df['EMA_20']).astype(int)
below_the_line = (result_df['Signal'] == 1).mean() * 100
if below_the_line > 85:
return "Long"
return None
pd.set_option("display.max_rows", None, "display.max_columns", None)
long_list = []
short_list = []
stock_list = [
"TATASTEEL.NS", "ITCHOTELS.NS", "BHARTIARTL.NS", "JSWSTEEL.NS", "TRENT.NS", "HINDALCO.NS", "KOTAKBANK.NS",
"BAJAJ-AUTO.NS", "ULTRACEMCO.NS", "NTPC.NS", "HEROMOTOCO.NS", "TECHM.NS", "ADANIENT.NS", "INDUSINDBK.NS",
"EICHERMOT.NS", "HDFCLIFE.NS", "BAJAJFINSV.NS", "TITAN.NS", "BPCL.NS", "ASIANPAINT.NS", "DRREDDY.NS",
"SBILIFE.NS", "SUNPHARMA.NS", "POWERGRID.NS", "NESTLEIND.NS", "AXISBANK.NS", "HCLTECH.NS", "CIPLA.NS",
"COALINDIA.NS", "TATACONSUM.NS", "WIPRO.NS", "MARUTI.NS", "HINDUNILVR.NS", "BAJFINANCE.NS", "TATAMOTORS.NS",
"GRASIM.NS", "LT.NS", "HDFCBANK.NS", "INFY.NS", "BEL.NS", "ONGC.NS", "SHRIRAMFIN.NS", "APOLLOHOSP.NS",
"RELIANCE.NS", "ICICIBANK.NS", "TCS.NS", "ADANIPORTS.NS", "BRITANNIA.NS", "SBIN.NS", "ITC.NS" ]
for stock in stock_list:
response = check_eligibility(stock)
if response == "Long":
long_list.append(stock)
elif response == "Short":
short_list.append(stock)
if long_list:
print("Stocks that are eligible for Long entry")
print(long_list)
else:
print("No Eligible Stocks for Long entry")
if short_list:
print("Stocks that are eligible for Short entry")
print(short_list)
else:
print("No Eligible Stocks for Short entry")
if not long_list and not short_list:
print("No Stocks Eligible")Limitations and Risks
Like any strategy, Reverse Gear isn't perfect:
- False Signals: Sometimes a stock will briefly cross the EMA only to continue its original trend
- Late Entries: If you're not monitoring the screener output constantly, you might miss the ideal entry
- Slippage: Especially on less liquid stocks, entry and exit prices may differ from your targets
- Overnight Risk: Always close positions before market close to avoid carrying overnight risk
How I Backtested This
I have a full-fledged backtesting framework in Python, built to test trading strategies with precision.
This is the same framework I teach in my course: Backtesting Trading Strategies using AI and Python. If you want to learn how to build such backtesters, test strategies like this one, and validate them with real numbers, you can check out the course here: [Link to Course].
And if you’re someone who wants to go one step further – not just test strategies but actually deploy them in real markets in full auto mode – I also run a course on Building a Complete Algo Trading System in Python.
In that program, I cover how to:
- Automate your strategies from end to end.
- Run them on an AWS server 24/7.
- Implement risk and money management.
- Build a real-time monitoring dashboard.
- Even manage trades from a Telegram bot.
Basically, it’s everything you need to go from a backtested strategy to a production-grade automated system. You can learn more about that here: [Link to Course].
Conclusion
The Reverse Gear strategy represents a disciplined approach to capturing intraday reversals with clearly defined entry and exit points. What I appreciate most about this system is its objective nature - there's no guesswork involved.
If you decide to try this strategy, I recommend paper trading it first to get comfortable with the mechanics and to observe how it performs across different market conditions. Remember that consistent application of rules and proper risk management are far more important than occasional home runs.
Feel free to modify the screener code to fit your preferences, and let me know in the comments if you have any questions or suggestions for improvements!
Happy trading,
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...
