Understanding RSI Divergence for Better Trade Entries
How to identify and trade RSI divergence patterns using real-time API data. Includes code examples and backtesting results.
RSI divergence is one of the most powerful signals in technical analysis. When price makes a new high but RSI doesn't, it often signals an impending reversal. Here's how to detect and trade it programmatically.
What is RSI Divergence?
Divergence occurs when the price and an indicator move in opposite directions. There are two types:
Bullish Divergence
Price makes a lower low, but RSI makes a higher low. Signals weakening downward momentum — potential reversal upward.
Bearish Divergence
Price makes a higher high, but RSI makes a lower high. Signals weakening upward momentum — potential reversal downward.
Detecting Divergence with the API
Use the TickAtlas API to fetch historical RSI and price data, then compare peaks and troughs:
GET /v1/indicator?symbol=EURUSD&indicator=RSI_14&timeframe=H1&bars=50
# Compare the last two RSI troughs against the last two price lows
# If price_low_2 < price_low_1 but rsi_low_2 > rsi_low_1
# = Bullish divergence detected Trading Rules
- Entry: After bullish divergence confirmed on H1, enter long when RSI crosses above 30
- Confirmation: Look for MACD histogram turning positive for additional confluence
- Stop loss: Below the most recent swing low (the second lower low)
- Take profit: Previous resistance level or 2:1 reward-to-risk ratio
- Timeframe: Most reliable on H1 and H4. Avoid M1/M5 (too noisy)
Common Mistakes
Trading divergence against the trend
Bullish divergence in a strong downtrend often fails. Always check ADX and higher timeframe trend first.
Entering too early
Divergence signals the potential for reversal, not the reversal itself. Wait for confirmation (RSI crossing key levels).
Ignoring the timeframe
Divergence on M5 is far less reliable than on H4 or D1. Higher timeframes give stronger signals.
Related Reading
Try this with live data
Every account gets $2.50 in free PAYG credits. No card required — paste your API key and run the code above against live broker data.
Keep reading
All articles- Tutorial 11 min read
24/7 Crypto Monitoring: Building Always-On Analysis Systems
Build a monitoring system that watches crypto markets around the clock, detects significant moves, and sends alerts when conditions match your criteria.
March 28, 2026
- Analysis 9 min read
ADX: How to Measure Trend Strength in Your Trading Bot
Learn how the ADX indicator measures trend strength, not direction, and how to use it as a filter to dramatically improve your bot's signal quality.
March 28, 2026
- Tutorial 12 min read
How to Build an AI Market Analyst That Runs 24/7
Build a production-ready AI market analyst that monitors forex and crypto markets around the clock, generates daily briefings, and alerts you to opportunities via Telegram.
March 28, 2026