Price Action Indicators

Doji: Indecision Candlestick | AlfaTactix

📖 6 min read

📝 1,168 words

🏷️ Price Action Indicators

In this page: what Doji is, how it works, when to use it, a practical example with code, and a bonus tip.

Use Doji in a real strategy—no code required

Create a free account to save your progress and build strategies with this indicator and 80+ others in minutes. Backtest, then export to MQL5.


Doji on a price chart: illustration of the indicator and how it is used in technical analysis
Doji – chart illustration

Doji Indicator Explanation

The Doji is a single-candlestick price action pattern that indicates market indecision and potential trend reversals by showing that the opening and closing prices are nearly equal. The Doji pattern has a very small body (the difference between open and close is minimal) with upper and lower wicks (shadows) of varying lengths. The pattern represents a battle between buyers and sellers where neither side gains control, resulting in price closing near where it opened. Doji patterns are highly regarded in candlestick analysis for their ability to signal potential trend exhaustion and reversal points, particularly when they occur at key support or resistance levels or after strong trends.

How Doji Works: A Doji is identified by its distinctive shape: a very small body (ideally open equals close) with wicks extending above and below. The most common types of Doji include: Standard Doji (equal upper and lower wicks), Long-Legged Doji (long wicks on both sides, indicating high volatility and strong indecision), Gravestone Doji (long upper wick, no lower wick, body at bottom, bearish reversal signal), and Dragonfly Doji (long lower wick, no upper wick, body at top, bullish reversal signal). The significance of a Doji increases when it occurs after a strong trend, at support or resistance levels, or with high volume. A Doji at the top of an uptrend suggests potential bearish reversal, while a Doji at the bottom of a downtrend suggests potential bullish reversal.

When to Use Doji:

  • Indecision and Reversal Identification: Doji patterns are highly effective at identifying market indecision and potential trend reversals. A Doji after a strong uptrend suggests that buyers and sellers are in balance, potentially signaling trend exhaustion and bearish reversal. A Doji after a strong downtrend suggests potential bullish reversal.
  • Support and Resistance Confirmation: Doji patterns can confirm support and resistance levels when they form at these key levels. A Doji at support suggests potential upward reversal, while a Doji at resistance suggests potential downward reversal. The indecision pattern indicates uncertainty at these levels.
  • Entry and Exit Signals: Doji patterns can generate entry and exit signals when combined with other confirmation. A bullish Doji (Dragonfly) at support can signal a buy entry, while a bearish Doji (Gravestone) at resistance can signal a sell entry. However, Doji patterns work best when confirmed by subsequent price action.

Advantages:

  • Provides clear visual signals of market indecision, making it easy to identify potential reversal points. The distinctive shape makes Doji patterns easy to spot on charts.
  • Works effectively across multiple timeframes and asset classes, including stocks, forex, commodities, and cryptocurrencies. The pattern is universal and reflects human psychology in trading.
  • Helps identify trend exhaustion and potential reversals through indecision signals, providing valuable information for risk management and trade placement.

Limitations:

  • Doji patterns can produce false signals in ranging markets when they occur frequently without clear directional bias. The pattern works best when combined with trend analysis and support/resistance levels.
  • The indicator may require confirmation from subsequent price action, as Doji patterns alone do not guarantee reversals. Not all Doji patterns are equally reliable, and context is crucial.
  • Doji patterns alone do not provide information about trend direction or strength, only potential indecision and reversal points. Traders should combine them with other indicators for more comprehensive analysis.

In summary, Doji is a valuable price action pattern that identifies market indecision and potential trend reversals, making it ideal for identifying exhaustion points and generating entry and exit signals. For comprehensive understanding, refer to candlestick analysis literature, including Steve Nison's "Japanese Candlestick Charting Techniques" (1991), Investopedia's Doji guide, TradingView's Doji documentation, and academic research on candlestick patterns in technical analysis published in journals such as the Journal of Financial Markets and the Review of Financial Studies.

Practical Example: Using the Doji Indicator in a Trading Strategy

The Doji is a price action pattern used to identify market indecision and potential trend reversals through indecision signals. In a trading strategy, the Doji indicator helps traders identify trend exhaustion points and generate entry and exit signals based on market indecision.

Scenario: You're creating a reversal strategy for Bitcoin (BTC/USDT) on a 1-hour chart. You want to buy when a bullish Doji (Dragonfly) forms at a support level after a downtrend (indicating potential upward reversal), and sell when a bearish Doji (Gravestone) forms at a resistance level after an uptrend (indicating potential downward reversal).

Strategy Logic:

  • Identify Doji patterns: a very small body (open ≈ close) with wicks extending above and below. Dragonfly Doji (long lower wick, bullish) and Gravestone Doji (long upper wick, bearish) are the most significant reversal patterns.
  • Buy signal: When a Dragonfly Doji forms at a support level after a downtrend, indicating market indecision and potential bullish reversal.
  • Sell signal: When a Gravestone Doji forms at a resistance level after an uptrend, indicating market indecision and potential bearish reversal.

Backtrader Example:

import backtrader as bt

class DojiReversalStrategy(bt.Strategy):
    params = dict(
        doji_body_ratio=0.1  # Body must be less than 10% of range
    )
    
    def __init__(self):
        self.support_level = None  # Set based on your analysis
        self.resistance_level = None  # Set based on your analysis
        
    def is_doji(self, bar):
        """Check if current bar is a Doji"""
        body = abs(bar.close - bar.open)
        range_size = bar.high - bar.low
        return body <= range_size * self.p.doji_body_ratio
    
    def is_dragonfly_doji(self, bar):
        """Check if current bar is a Dragonfly Doji (bullish)"""
        if not self.is_doji(bar):
            return False
        lower_wick = min(bar.open, bar.close) - bar.low
        upper_wick = bar.high - max(bar.open, bar.close)
        body = abs(bar.close - bar.open)
        return lower_wick > body * 2 and upper_wick < body
    
    def is_gravestone_doji(self, bar):
        """Check if current bar is a Gravestone Doji (bearish)"""
        if not self.is_doji(bar):
            return False
        lower_wick = min(bar.open, bar.close) - bar.low
        upper_wick = bar.high - max(bar.open, bar.close)
        body = abs(bar.close - bar.open)
        return upper_wick > body * 2 and lower_wick < body
        
    def next(self):
        current_bar = self.data[0]
        
        if not self.position:
            # Buy when Dragonfly Doji at support after downtrend
            if (self.is_dragonfly_doji(current_bar) and 
                self.data.low[0] <= self.support_level * 1.001 and
                self.data.close[-5] > self.data.close[0]):  # Downtrend
                self.buy()
        else:
            # Sell when Gravestone Doji at resistance after uptrend
            if (self.is_gravestone_doji(current_bar) and 
                self.data.high[0] >= self.resistance_level * 0.999 and
                self.data.close[-5] < self.data.close[0]):  # Uptrend
                self.sell()

# Usage
cerebro = bt.Cerebro()
cerebro.addstrategy(DojiReversalStrategy)

Expected Outcome: By using the Doji indicator, your strategy identifies market indecision and potential trend reversals, helping you enter trades when trends are exhausted and exit when new indecision patterns form. This approach leads to better reversal identification, improved trend exhaustion recognition, and enhanced entry timing by trading indecision patterns.

💡 Bonus Tip

Consider using Doji patterns in combination with volume analysis for confirmation. When a Doji forms with high volume, it suggests stronger indecision and higher probability of reversal. When a Doji forms with low volume, it may be less significant. This technique, documented in candlestick analysis literature, can significantly improve the accuracy of Doji-based trading strategies.

Using the Doji indicator ensures your strategy trades indecision patterns effectively, improving entry and exit timing based on objective price action analysis.

Use Doji in a real strategy—no code required

Create a free account to save your progress and build strategies with this indicator and 80+ others in minutes. Backtest, then export to MQL5.

Try Strategy Builder

Use this indicator in Strategy Builder — free

Create free account