Bullish and Bearish Harami Detector: Advanced Candlestick Pattern Indicator

·

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

Whether you're a day trader analyzing 1-hour charts or a swing trader focused on daily timeframes, this Pine Script-based tool enhances your ability to spot high-probability reversal setups—without manual chart scanning.


What Is the Bullish and Bearish Harami Pattern?

Before diving into the indicator’s features, it's essential to understand the core patterns it detects.

Bullish Harami: A Sign of Trend Reversal Upward

A Bullish Harami occurs during a downtrend when a large bearish candle is followed by a smaller bullish candle whose body is entirely contained within the previous candle’s body. This "pregnant" formation (the term Harami means "pregnant" in Japanese) suggests weakening selling pressure and the potential start of a bullish reversal.

👉 Discover how advanced technical tools can help you spot reversals earlier.

Bearish Harami: Warning of Downward Momentum

Conversely, a Bearish Harami appears after an uptrend. It consists of a large bullish candle followed by a smaller bearish candle, again with the second candle’s body fully nested inside the first. This pattern indicates that buying momentum is fading and sellers may soon take control.

Recognizing these patterns promptly can significantly improve entry timing and risk management—especially when combined with volume, support/resistance levels, or other confirmatory indicators.


Key Features of the Harami Detector Indicator

This custom Pine Script indicator goes beyond basic pattern recognition by offering full user control and dynamic visualization. Here's what makes it stand out:

Timeframe Flexibility for Any Trading Style

One of the most valuable aspects of this tool is its customizable timeframe selection. Using the input.timeframe function, traders can apply the detection logic to any interval—be it 15 minutes, 1 hour, 4 hours, or daily candles.

This flexibility allows:

No matter your strategy, aligning pattern detection with your preferred timeframe increases signal relevance.

Toggle-Based Pattern Detection

Not all traders want both signals active at once. That’s why the script includes two independent toggles:

You can enable only the pattern type relevant to your current market bias. For example, if you're watching for bottoming action in a crypto asset, simply turn on Bullish Harami detection and filter out noise from bearish signals.

This modular design improves focus and reduces visual clutter on your chart.

Custom Pre-Pattern Trend Filters

A true reversal pattern should occur within context—a prior trend. To ensure validity, this indicator allows users to define how many consecutive candles must precede the harami formation:

These inputs—bearishCandleCountBullish and bullishCandleCountBearish—add a layer of trend confirmation, reducing false positives and increasing statistical edge.


How the Detection Logic Works

The script uses precise mathematical comparisons between open, close, high, and low values to identify valid harami formations.

Bullish Harami Conditions:

  1. Previous candle is bearish (open > close)
  2. Current candle is bullish (open < close)
  3. Entire body of current candle fits within the body of previous candle
  4. Preceded by user-defined number of bearish candles

Bearish Harami Conditions:

  1. Previous candle is bullish (open < close)
  2. Current candle is bearish (open > close)
  3. Entire body of current candle fits within the body of previous candle
  4. Preceded by user-defined number of bullish candles

Once all conditions are met, the script plots a visual marker using TradingView’s plotshape() function.


Visual Alerts for Instant Recognition

Clarity is critical when monitoring fast-moving markets. This indicator plots easy-to-spot labels directly on the chart:

These annotations update in real time as new candles form, ensuring you never miss a setup. Tooltips and descriptive input labels make the interface intuitive—even for traders new to candlestick analysis.


Practical Use Cases for Traders

Day Trading Crypto or Forex

In volatile markets like cryptocurrency or forex, short-term harami patterns often precede sharp bounces or pullbacks. By setting the timeframe to 15m or 1h and requiring just 2–3 prior trend candles, scalpers can catch early reversals with tight stop-loss placements.

Swing Trading Stocks or Indices

For longer-term plays, apply the indicator to daily charts with stricter pre-trend requirements (e.g., 5+ bullish candles before a Bearish Harami). Combine with RSI divergence or Fibonacci retracements for stronger confluence.

👉 Learn how professional traders integrate pattern recognition into their decision-making process.

Multi-Timeframe Confirmation

Use the indicator on both 4-hour and daily charts simultaneously. A Bullish Harami appearing on both timeframes increases confidence in a major reversal—ideal for position entries with extended profit targets.


Frequently Asked Questions (FAQ)

Q: Can this indicator be used on any asset class?
A: Yes. The script works across all instruments available on TradingView—stocks, forex, cryptocurrencies, commodities, and indices—since candlestick patterns are universal.

Q: Does it repaint or lag after the candle closes?
A: No. The detection occurs only after the current candle has closed, ensuring no repainting. This makes it suitable for backtesting and live trading.

Q: How do I adjust sensitivity to avoid too many signals?
A: Increase the required number of prior trend candles (e.g., set bearishCandleCountBullish to 6). This ensures patterns only trigger after stronger trends, improving reliability.

Q: Can I combine this with volume or moving averages?
A: Absolutely. While not built-in, you can overlay volume indicators or EMAs manually on TradingView to add confirmation layers.

Q: Is coding knowledge needed to use this?
A: Not at all. Once added to your chart, all settings are accessible via simple dropdowns and number inputs in the indicator’s configuration panel.


Why This Tool Belongs in Your Technical Arsenal

Reversal patterns like the Bullish Harami and Bearish Harami offer more than just aesthetic symmetry—they represent shifts in market psychology. When sellers exhaust themselves and buyers step in cautiously (or vice versa), these small-bodied candles nestled within larger ones reflect uncertainty turning into opportunity.

With this customizable detector, you gain:

And because it runs natively on TradingView, integration is seamless—no external software or downloads required.

👉 Start applying smart pattern detection to your trading strategy today.


Final Thoughts

The Bullish and Bearish Harami Detector is more than just an alert system—it's a disciplined approach to price action trading. By combining classical charting wisdom with modern scripting capabilities, it empowers traders to act decisively when momentum shifts occur.

Whether you're refining an existing strategy or building a new one from scratch, integrating this indicator can elevate your technical analysis with clarity, consistency, and confidence.

Remember: Always test new tools in a demo environment and combine pattern signals with risk management principles for optimal results.