Bullish and Bearish Harami Detector: Advanced Candlestick Pattern Recognition

·

Candlestick patterns have long been a cornerstone of technical analysis, offering traders visual cues about potential market reversals. Among the most reliable of these formations are the Bullish Harami and Bearish Harami—two reversal patterns that signal a shift in market sentiment after a sustained trend. This article explores a powerful TradingView indicator designed to automatically detect these patterns with precision, customizable settings, and real-time visual alerts.

Whether you're a day trader analyzing 1-hour charts or a swing trader monitoring daily price action, this tool enhances your ability to spot high-probability turning points—before they fully materialize.

👉 Discover how advanced pattern detection can elevate your trading strategy.

Understanding the Bullish and Bearish Harami Patterns

At the heart of this indicator lies a clear understanding of two classic Japanese candlestick formations.

What Is a Bullish Harami?

A Bullish Harami occurs during a downtrend and suggests that selling pressure is weakening. It consists of two candles:

This "pregnant" appearance—where the second candle is nestled inside the first—gives the pattern its name ("Harami" means "pregnant" in Japanese). It signals hesitation among sellers and potential for an upward reversal.

What Is a Bearish Harami?

Conversely, a Bearish Harami forms during an uptrend and hints at diminishing buying momentum. It features:

Like its bullish counterpart, this pattern reflects indecision and may precede a bearish reversal.

These patterns are not standalone signals but gain strength when confirmed by volume, support/resistance levels, or additional indicators.

Key Features of the Harami Detector Indicator

This custom Pine Script indicator goes beyond basic pattern recognition by offering traders full control over detection parameters. Built for TradingView, it combines flexibility with accuracy.

Timeframe Selection for Strategic Flexibility

One of the most valuable features is customizable timeframe selection. Traders can analyze patterns across different time horizons—such as 1-hour, 4-hour, or daily charts—without switching views.

Using the input.timeframe function, users select their preferred timeframe directly from the settings panel. This ensures the indicator adapts to various trading styles, from short-term scalping to long-term investing.

👉 See how multi-timeframe analysis improves trade accuracy.

Selective Pattern Detection

Not every trader wants both signals active at once. That’s why the script includes toggle switches:

This selective filtering helps traders focus only on relevant signals based on current market conditions.

Custom Pre-Pattern Trend Confirmation

To reduce false positives, the indicator allows users to define how many consecutive candles must precede a valid pattern:

For example, setting bearishCandleCountBullish = 3 means the indicator will only flag a Bullish Harami if it follows at least three red candles—an effective way to confirm trend context.

Visual Alerts for Instant Recognition

When a valid pattern is detected, the script plots intuitive labels directly on the chart:

These visual cues use TradingView’s plotshape function and are designed for clarity, ensuring traders never miss a setup—even during fast-moving markets.

Additionally, input fields include tooltips and descriptions, making the tool accessible even to those new to candlestick analysis.

How the Indicator Works: Behind the Scenes

The script operates through a structured logic flow that ensures accurate and timely detection:

  1. Timeframe Synchronization: The script fetches price data based on the user-selected timeframe using request.security(), aligning detection with the desired market view.
  2. Candle Evaluation: It evaluates each candle’s open, close, high, and low values to determine whether it’s bullish or bearish.
  3. Pattern Matching: Using conditional checks, it verifies if:

    • The second candle’s body is fully within the first candle’s body.
    • The required number of prior trend-confirming candles exists.
  4. Signal Plotting: Upon confirmation, it triggers a visual label at the appropriate location on the chart.
  5. Real-Time Updates: As new candles form, the script continuously reassesses conditions, providing dynamic feedback.

Because Pine Script executes on every bar update, traders receive near-instantaneous alerts—critical for timely entries.

Practical Use Cases and Trading Applications

This indicator serves multiple roles across different trading strategies.

Swing Trading Reversals

Swing traders can apply the detector on 4-hour or daily charts to identify potential turning points after extended moves. For instance, spotting a Bearish Harami after five consecutive green candles near a known resistance level increases confidence in taking profit or entering short positions.

Day Trading with Confirmation Tools

Day traders might use the indicator on lower timeframes (e.g., 5-minute or 15-minute charts) but pair it with volume analysis or RSI divergence for stronger confirmation. A Bullish Harami forming at a key support zone with rising volume becomes a compelling long opportunity.

Backtesting and Strategy Development

The script's structured logic makes it ideal for integration into automated trading systems or backtesting frameworks. Traders can assess historical performance of Harami patterns under various market conditions and refine entry/exit rules accordingly.

Frequently Asked Questions (FAQ)

Q: Can this indicator predict market reversals with 100% accuracy?
A: No indicator guarantees perfect predictions. While Bullish and Bearish Harami patterns suggest potential reversals, they should be used alongside other tools like trendlines, volume, or oscillators for higher-confidence trades.

Q: Does it work on all assets?
A: Yes. The script functions on any asset available on TradingView—stocks, forex pairs, cryptocurrencies, and commodities—as long as candlestick data is available.

Q: How can I reduce false signals?
A: Increase the required number of prior trend candles (e.g., set bearishCandleCountBullish to 5). You can also combine alerts with horizontal support/resistance levels or moving averages.

Q: Is coding knowledge needed to use this?
A: Not at all. The indicator comes pre-built with user-friendly inputs. Simply add it to your chart and adjust settings via the UI panel.

Q: Can I use this for automated trading?
A: While this version focuses on visual alerts, the underlying logic can be adapted for strategy scripts that generate entry/exit orders in Pine Script.

👉 Learn how integrating technical signals can optimize your trading decisions.

Final Thoughts: Enhance Your Technical Edge

The Bullish and Bearish Harami Detector is more than just a pattern scanner—it's a customizable analytical tool that brings discipline and clarity to technical trading. By combining classical charting wisdom with modern automation, it empowers traders to act faster and more confidently.

With adjustable timeframes, selective detection, and visual alerts, this indicator fits seamlessly into diverse trading workflows. Whether you're scanning for reversals in crypto markets or evaluating stock trends, harnessing these subtle yet powerful signals could make all the difference.

Remember: successful trading isn’t about finding one “magic” indicator—it’s about combining multiple forms of evidence to tilt probabilities in your favor. This tool gives you one more edge in that ongoing quest.

Keywords: Bullish Harami, Bearish Harami, candlestick patterns, TradingView indicator, reversal patterns, technical analysis, Pine Script, pattern detection