Doji

FXC911 – Forex & Crypto News & Insights

What is a Doji Candle?

A Doji candle is a type of candlestick pattern that occurs when the opening and closing prices of a financial asset are virtually the same, resulting in a small or non-existent body with long wicks (shadows) on both sides. It indicates indecision in the market, as neither buyers nor sellers have been able to gain control.

Types of Doji Candles

  1. Neutral Doji: Equal length wicks on both sides, indicating market indecision.

  2. Long-legged Doji: Long wicks on both sides, showing extreme indecision.

  3. Dragonfly Doji: A long lower wick with little to no upper wick, suggesting a potential bullish reversal.

  4. Gravestone Doji: A long upper wick with little to no lower wick, indicating a potential bearish reversal.

Types of Doji Candles

Application of Doji Candles

  1. Trend Reversals: Doji candles often appear at the top or bottom of trends, signaling a possible reversal.

  2. Support and Resistance Levels: When appearing at significant support or resistance levels, Doji candles can strengthen the likelihood of a reversal.

  3. Market Indecision: A Doji within a trend can indicate indecision, suggesting that the current trend may be losing strength.

Pine Script Code: Identifying Doji Candles

Here's a Pine Script code to identify Doji candles and interpret them:

///@version=5
indicator("Doji Candle Identifier", overlay=true)

// Define the Doji threshold as a small percentage of the total range
dojiThreshold = 0.1

// Calculate the candle components
candleBodySize = abs(close - open)
candleRange = high - low

// Identify Doji candles
isDoji = candleBodySize <= (dojiThreshold * candleRange)

// Plot Doji candles
plotshape(isDoji, title="Doji", location=location.abovebar, color=color.yellow, style=shape.cross, size=size.small)

// Label for Doji candles
var label dojiLabel = na
if (isDoji)
    dojiLabel := label.new(x=bar_index, y=high, text="Doji", color=color.black, textcolor=color.white, size=size.small)
else
    label.delete(dojiLabel)

Explanation of the Code

1. Define the Indicator:

indicator("Doji Candle Identifier", overlay=true)

This line sets up the indicator to be plotted on the price chart.

2. Define the Doji Threshold:

dojiThreshold = 0.1

The threshold is set to 10% of the candle range to identify Doji candles.

3. Calculate Candle Components:

candleBodySize = abs(close - open)
candleRange = high - low

These lines calculate the body size and the total range of each candle.

4. Identify Doji Candles:

isDoji = candleBodySize <= (dojiThreshold * candleRange)

This line checks if the candle body size is less than or equal to 10% of the total range, marking it as a Doji candle.

5. Plot Doji Candles:

plotshape(isDoji, title="Doji", location=location.abovebar, color=color.yellow, style=shape.cross, size=size.small)

This line plots a cross above bars identified as Doji candles.

6. Label Doji Candles:

var label dojiLabel = na
if (isDoji)
    dojiLabel := label.new(x=bar_index, y=high, text="Doji", color=color.black, textcolor=color.white, size=size.small)
else
    label.delete(dojiLabel)

This block creates a label for Doji candles and deletes the label when the condition is no longer met.

Keywords

Doji, candlestick pattern, market indecision, trend reversal, neutral Doji, long-legged Doji, dragonfly Doji, gravestone Doji, technical analysis, support levels, resistance levels, price action, candlestick analysis, trading signals, market psychology

Visit me on:

Last updated