Candlestick Pattern Detector

Portfolio Analytics Intermediate Equity ETFs Futures Options Forex Commodities Indices
Backtest Candlestick Pattern Detector on real market data — free
Simulate it in AlgoKing with zero real-money risk. No card required.
Start free →

Quick Reference

Purpose Automatically detect, classify, and validate Japanese candlestick patterns from OHLC price data to identify potential reversal and continuation signals
Core Function Analyzes individual and multi-candle formations to identify classic candlestick patterns including doji, hammer, engulfing, morning/evening stars, and dozens of other recognized formations
Primary Users Technical traders, price action traders, swing traders, and algorithmic systems requiring automated candlestick analysis
Key Benefit Provides objective, consistent pattern detection across multiple instruments, removing subjectivity and ensuring no patterns are missed
Data Sources OHLC (Open, High, Low, Close) price data with optional volume
Update Frequency Real-time pattern detection on each new candle completion
Indian Context Calibrated for Indian market characteristics including gap behavior, session timing, and F&O expiry effects
Typical Outputs Ranked list of detected patterns with type, direction bias, confidence score, and contextual relevance
Risk Consideration Candlestick patterns are short-term signals requiring confirmation - use with broader technical context

India-Specific Notes

Market Characteristics

Trading Hours 9:00 AM - 9:08 AM IST (price discovery session) • 9:15 AM - 3:30 PM IST • 3:40 PM - 4:00 PM IST • First candle (9:15-9:30) often volatile; patterns more reliable mid-session
Gap Behavior Frequent gaps due to global market movements overnight • Gaps can create doji or spinning tops that are context-dependent • Gap-up opening candles need different interpretation than intraday patterns
Volatility Patterns High volatility 9:15-9:45 AM creates large-body candles • Lower volatility 12:00-1:30 PM - smaller candles, more dojis • Increased activity 2:30-3:30 PM affects pattern formation • Thursday expiry days see unusual candlestick behavior

Index Specific

Nifty 50 Daily range 100-300 points in normal conditions • Body > 100 points considered significant • Long shadows at round numbers (22000, 22500) more significant • Doji at resistance, hammers at support levels
Bank Nifty Daily range 300-800 points (more volatile) • Body > 250 points considered significant • More reversal patterns due to volatility • 15-min and hourly patterns more actionable

Fno Considerations

Expiry Effects Thursday patterns near max pain levels less reliable • Last week of month - patterns may be distorted by rollover • Patterns on Monday-Wednesday more reliable than Thursday
Options Influence Price may form doji/spinning tops near high OI strikes • Dealer hedging can create unusual candle formations • Patterns pulling toward max pain may reverse post-expiry

Data Sources

Nse Data NSE website for historical OHLC
Broker Apis Zerodha Kite, Angel One, Upstox for real-time OHLC
Charting Platforms TradingView, ChartIQ for visualization

Frequently Asked Questions

How reliable are candlestick patterns for trading?

Candlestick patterns have varying reliability, typically 50-65% success rate when properly contextualized. No pattern works all the time. Reliability increases significantly when patterns appear: (1) After clear prior trends for reversal patterns, (2) At key support/resistance levels, (3) With volume confirmation, (4) Aligned with higher timeframe direction. Always use patterns as one tool among several, with proper risk management. A 55% win rate with 2:1 reward-to-risk is profitable.

Should I wait for confirmation before trading a candlestick pattern?

It depends on the pattern type: Strong patterns (engulfing, morning/evening star, three soldiers/crows): Can trade on pattern completion, though confirmation improves odds. Moderate patterns (hammer, shooting star, piercing line): Confirmation candle is recommended. Weak patterns (harami, doji, spinning top): Always wait for confirmation. Confirmation means the next candle closes in the expected direction. This extra patience significantly improves success rates, though you may miss some fast moves.

Do candlestick patterns work on all timeframes?

Candlestick patterns can form on any timeframe, but reliability varies. Higher timeframes (daily, weekly) are more reliable because they represent more significant price action and are watched by more traders. Lower timeframes (5-min, 15-min) have more patterns but also more noise. Match your timeframe to your trading style: day traders use intraday patterns, swing traders use daily patterns. A daily hammer is more significant than a 5-minute hammer.

What's the difference between a doji and a spinning top?

Both indicate indecision, but with subtle differences. Doji: Open and close are essentially equal (very thin or no body). Pure equilibrium - complete stalemate between buyers and sellers. Spinning Top: Has a small body (but larger than doji) with shadows on both sides. Slight lean toward one direction but still indecision. In practice, both signal uncertainty. Doji at key levels after trends are more significant. Spinning tops are milder indecision signals.

How many candlestick patterns should I learn to trade effectively?

Start with mastering 5-8 core patterns: hammer, shooting star, doji, bullish engulfing, bearish engulfing, morning star, evening star, and three soldiers/crows. These cover the main reversal and continuation signals. Once you're consistently profitable with these, you can add others. Quality over quantity matters - it's better to trade a few patterns well than many patterns poorly. Most successful candlestick traders focus on a limited set they know intimately.

How do I handle candlestick patterns during earnings or major news?

News events require caution with candlestick patterns: Before event: Patterns may be invalidated by the event. Consider reducing size or waiting. During event: Candlesticks will be erratic and potentially meaningless (volatility, not pattern). After event: Wait for dust to settle (at least 1-2 candles). Then analyze new patterns that form in the post-event context. Best approach: Trade patterns that form after the news has been absorbed, not those that exist before the event.

What's the relationship between candlestick patterns and support/resistance?

Candlestick patterns and S/R levels are highly complementary. Patterns tell you WHAT (reversal or continuation signal). S/R tells you WHERE (significant price levels). The combination is powerful: A hammer at support = two signals agreeing = high probability buy. A shooting star at resistance = two signals agreeing = high probability sell. Always identify S/R levels first, then look for candlestick patterns at those levels. Patterns in 'empty space' without S/R context are less reliable.

How should I handle conflicting candlestick patterns?

When patterns conflict: (1) Priority by timeframe: Higher timeframe pattern wins. Daily bullish beats hourly bearish. (2) Priority by quality: Strong pattern (engulfing, star) over weak (harami, doji). (3) Priority by context: Pattern at S/R level over pattern in mid-range. (4) When truly conflicting: Reduce size significantly or skip the trade entirely. Conflicting signals suggest uncertainty - why take risk when signals disagree? Wait for clearer setup.

Can candlestick patterns be automated for scanning?

Yes, candlestick patterns can be automated effectively. Translate visual pattern rules into mathematical conditions (body ratios, shadow ratios, position within range, etc.). Most patterns have objective definitions that can be coded. Benefits: Consistent detection, no missed patterns, ability to scan many instruments. Challenges: Context (prior trend) requires additional logic; some patterns have subjective elements. Best approach: Use automation for detection and alerting, but apply human judgment for context and final trade decisions.

How do gaps affect candlestick pattern interpretation?

Gaps add important context to candlestick patterns: Gap + pattern: A morning star with gaps (classic version) is stronger than one without. Gap-up doji at resistance is more bearish than no-gap doji. Failed gap: Gap up followed by bearish engulfing is very bearish (gap filled and reversed). Indian context: Overnight gaps are common due to global markets. Interpret gap patterns carefully - a gap-up hammer has different psychology than a normal hammer. Track gap fill behavior for additional context.

How can machine learning improve candlestick pattern trading?

ML can enhance candlestick trading in several ways: (1) Pattern classification: Train models to identify patterns from raw OHLC data, potentially finding patterns humans miss. (2) Success prediction: Given a detected pattern, predict likelihood of success based on context features (trend, volume, S/R proximity, indicators). (3) Optimal thresholds: Learn optimal detection thresholds for different regimes. (4) Feature importance: Understand which factors most predict pattern success. Best approach: Use rule-based detection for patterns, ML for scoring/filtering. Validate rigorously with walk-forward testing.

How should candlestick detection parameters adapt to different market regimes?

Adaptive parameters improve performance across regimes: High volatility: Increase body thresholds (larger moves needed for significance), widen shadow ratios, expect shorter pattern durations. Low volatility: Decrease thresholds, tighter ratios, longer pattern durations acceptable. Trending markets: Prioritize continuation patterns, require stronger signals for reversals. Ranging markets: Prioritize reversal patterns at range boundaries. Implementation: Calculate regime indicators (ATR percentile, ADX), map to parameter adjustments, update dynamically or at regime changes.

What are the key challenges in building production candlestick systems?

Key production challenges: (1) Data quality: Ensuring clean OHLC data without gaps, handling corporate actions (splits, bonuses). (2) Latency: Processing patterns fast enough for real-time alerts without missing candle closes. (3) Scalability: Scanning thousands of instruments efficiently. (4) Parameter stability: Thresholds that work across instruments and market conditions. (5) Integration: Clean APIs for trading systems, proper order management. (6) Monitoring: Tracking pattern quality over time, detecting degradation. Solutions: Robust data pipelines, efficient parallel processing, adaptive parameters, comprehensive monitoring.

How do institutional traders use and potentially exploit candlestick patterns?

Institutional awareness of patterns: (1) Many institutions use pattern-based systems or are aware retail traders do. (2) They may exploit obvious patterns: triggering stops by pushing through pattern extremes briefly, creating false patterns that fail, front-running obvious pattern breakouts. (3) Institutional flow can overwhelm pattern signals - their size moves markets regardless of patterns. Defense strategies: Use confirmation and volume requirements, place stops at less obvious levels, be suspicious of 'too perfect' patterns, combine patterns with flow analysis (options data, delivery %).

What metrics should be tracked to monitor candlestick pattern performance over time?

Key metrics to track: (1) Pattern success rate by type - compare to historical baselines. (2) Average return by pattern - are profits maintaining? (3) Win rate by context (at S/R, with volume, trend aligned). (4) Regime performance - success in bull/bear/choppy markets. (5) Time to resolution - how many bars until target/stop. (6) Failure rate and severity - are stops being hit more? Actions on degradation: Review detection parameters, check for market regime change, validate data quality, consider retraining ML models. Regular review (weekly/monthly) of these metrics catches issues early.

Related Strategies

Ready to test Candlestick Pattern Detector?

AlgoKing is a flight simulator for traders — real market data, real backtests, zero real-money risk.

Create your free account

Educational simulation platform. Not investment advice. No SEBI registration required.

AlgoKing Support
AI-powered • Instant answers
Hi! I'm AlgoKing's AI assistant. How can I help you today?
Pricing Plans Supported Brokers How to Start MCX Algorithms