Overview of Three White Soldiers Candlestick Pattern
The “Three White Soldiers” candlestick pattern is a bullish reversal pattern commonly observed in technical analysis of financial markets. Here’s an overview of its characteristics and implications:
- Formation: This pattern is formed over three trading sessions, each marked by a long-bodied candlestick. These candlesticks are typically white or green, indicating a close higher than the open.
- Market Context:
- This pattern is most significant when it appears after a downtrend, indicating a potential reversal of the bearish sentiment.
- It should be accompanied by increasing trading volume to validate the pattern’s strength and reliability.
- Implications:
- The “Three White Soldiers” pattern is considered a strong bullish signal, suggesting a shift in market sentiment from bearish to bullish.
- Traders often view this pattern as an opportunity to enter long positions or close short positions.
Importance in Technical Analysis
The “Three White Soldiers” candlestick pattern holds significant importance in technical analysis due to several reasons:
- Bullish Reversal Indicator: One of the primary importances of the “Three White Soldiers” pattern is its role as a bullish reversal indicator. When this pattern appears after a downtrend, it suggests a strong shift in market sentiment from bearish to bullish. This can be a crucial signal for traders and investors looking to capitalize on the early stages of a market upturn.
- Market Psychology Insight: This pattern provides insight into market psychology. The three consecutive long-bodied bullish candles indicate persistent buying pressure and a lack of significant selling pressure, suggesting a change in the attitudes and actions of market participants.
- Decision-Making Tool: For traders, the “Three White Soldiers” serve as a decision-making tool. It can signal the time to enter long positions or exit short positions, aligning trading strategies with the newly established bullish market trend.
- Volume Confirmation: The pattern often requires confirmation from trading volumes. An increase in volume during the formation of the “Three White Soldiers” adds credibility to the bullish signal, aiding traders in verifying the strength of the market’s reversal.
- Risk Management: Recognizing this pattern helps in risk management. Traders who understand the implications can adjust their stop-loss orders and take-profit points accordingly, managing their risk in response to a potential change in market direction.
Example From Trading View
Defining the Three White Soldiers Candlestick Pattern Criteria
The “Three White Soldiers” candlestick pattern is defined by specific criteria that must be met for it to be considered valid. These criteria are crucial for technical analysts and traders in identifying the pattern accurately. Here are the key criteria for the “Three White Soldiers” pattern:
- Preceding Downtrend: The pattern should emerge after a notable downtrend in the market. Its presence indicates a potential reversal of the previous bearish trend.
- Three Long Bullish Candlesticks: The pattern consists of three consecutive long-bodied candlesticks. These candles are typically white or green, indicating that the closing price is significantly higher than the opening price.
- Successive Higher Closes: Each of the three candlesticks should close higher than the previous day’s close. This ascending sequence of closes demonstrates increasing bullish sentiment.
- Opening Prices within Previous Candle’s Body: Each candlestick should open within the body of the previous candle. Ideally, the opening price should be in the lower half of the previous day’s candlestick. This overlap indicates that the bullish momentum is carrying over from the previous session.
Code For Detecting Three White Soldiers
//@version=5 indicator("Three White Soldiers - Bullish", shorttitle = "Three White Soldiers", overlay=true) C_Len = 14 // ta.ema depth for bodyAvg C_ShadowPercent = 5.0 // size of shadows C_ShadowEqualsPercent = 100.0 C_DojiBodyPercent = 5.0 C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body C_BodyHi = math.max(close, open) C_BodyLo = math.min(close, open) C_Body = C_BodyHi - C_BodyLo C_BodyAvg = ta.ema(C_Body, C_Len) C_SmallBody = C_Body < C_BodyAvg C_LongBody = C_Body > C_BodyAvg C_UpShadow = high - C_BodyHi C_DnShadow = C_BodyLo - low C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body C_WhiteBody = open < close C_BlackBody = open > close C_Range = high-low C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo C_BodyMiddle = C_Body / 2 + C_BodyLo C_ShadowEquals = C_UpShadow == C_DnShadow or (math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 C_Doji = C_IsDojiBody and C_ShadowEquals patternLabelPosLow = low - (ta.atr(30) * 0.6) patternLabelPosHigh = high + (ta.atr(30) * 0.6) label_color_bullish = input(color.blue, "Label Color Bullish") C_ThreeWhiteSoldiersBullishNumberOfCandles = 3 C_3WSld_ShadowPercent = 5.0 C_3WSld_HaveNotUpShadow = C_Range * C_3WSld_ShadowPercent / 100 > C_UpShadow C_ThreeWhiteSoldiersBullish = false if C_LongBody and C_LongBody[1] and C_LongBody[2] if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2] C_ThreeWhiteSoldiersBullish := close > close[1] and close[1] > close[2] and open < close[1] and open > open[1] and open[1] < close[2] and open[1] > open[2] and C_3WSld_HaveNotUpShadow and C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2] alertcondition(C_ThreeWhiteSoldiersBullish, title = "New pattern detected", message = "New Three White Soldiers – Bullish pattern detected") if C_ThreeWhiteSoldiersBullish var ttBullishThreeWhiteSoldiers = "Three White Soldiers\nThis bullish reversal pattern is made up of three long-bodied, green candles in immediate succession. Each one opens within the body before it and the close is near to the daily high." label.new(bar_index, patternLabelPosLow, text="Three White Soldiers", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishThreeWhiteSoldiers) bgcolor(ta.highest(C_ThreeWhiteSoldiersBullish?1:0, C_ThreeWhiteSoldiersBullishNumberOfCandles)!=0 ? color.new(color.blue, 90) : na, offset=-(C_ThreeWhiteSoldiersBullishNumberOfCandles-1))
Output
Overview of the script
1. Indicator Declaration
indicator("Three White Soldiers - Bullish", shorttitle = "Three White Soldiers", overlay=true)
indicator
: This function declares a new indicator."Three White Soldiers - Bullish"
: The name of the indicator.shorttitle
: Shorter name displayed on the chart.overlay=true
: The indicator will be drawn on the main chart (overlaying the price).
2. Parameter Initialization
C_Len = 14 // ta.ema depth for bodyAvg C_ShadowPercent = 5.0 // size of shadows C_ShadowEqualsPercent = 100.0 C_DojiBodyPercent = 5.0 C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body
- These lines define various parameters for the script, such as the length for the Exponential Moving Average (
ta.ema
) calculation, percentages for shadow sizes, and factors for candlestick analysis.
3. Calculation of Candlestick Components
C_BodyHi = math.max(close, open) C_BodyLo = math.min(close, open) C_Body = C_BodyHi - C_BodyLo C_BodyAvg = ta.ema(C_Body, C_Len) C_SmallBody = C_Body < C_BodyAvg C_LongBody = C_Body > C_BodyAvg C_UpShadow = high - C_BodyHi C_DnShadow = C_BodyLo - low
- These lines calculate key aspects of the candlesticks, like the high and low of the body, the body length, and the lengths of the upper and lower shadows.
4. Candlestick Characteristics
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body C_WhiteBody = open < close C_BlackBody = open > close C_Range = high-low C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo C_BodyMiddle = C_Body / 2 + C_BodyLo C_ShadowEquals = C_UpShadow == C_DnShadow or (math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 C_Doji = C_IsDojiBody and C_ShadowEquals
- These lines define more specific characteristics of the candlesticks, like whether they are white or black (bullish or bearish), if they have upper or lower shadows, and if they are Doji candles.
5. Pattern Recognition Logi
patternLabelPosLow = low - (ta.atr(30) * 0.6) patternLabelPosHigh = high + (ta.atr(30) * 0.6) label_color_bullish = input(color.blue, "Label Color Bullish") C_ThreeWhiteSoldiersBullishNumberOfCandles = 3 C_3WSld_ShadowPercent = 5.0 C_3WSld_HaveNotUpShadow = C_Range * C_3WSld_ShadowPercent / 100 > C_UpShadow C_ThreeWhiteSoldiersBullish = false if C_LongBody and C_LongBody[1] and C_LongBody[2] if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2] C_ThreeWhiteSoldiersBullish := close > close[1] and close[1] > close[2] and open < close[1] and open > open[1] and open[1] < close[2] and open[1] > open[2] and C_3WSld_HaveNotUpShadow and C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2]
- These lines set up the positions for labels, define the color for bullish labels, and establish the criteria for identifying the “Three White Soldiers” pattern. The script checks for three consecutive long, white (bullish) bodies, with each candle opening within the body of the previous candle and closing higher than the previous close. Additionally, it verifies that the candles do not have significant upper shadows.
6. Alerts and Background Coloring
alertcondition(C_ThreeWhiteSoldiersBullish, title = "New pattern detected", message = "New Three White Soldiers – Bullish pattern detected") if C_ThreeWhiteSoldiersBullish var ttBullishThreeWhiteSoldiers = "Three White Soldiers\nThis bullish reversal pattern is made up of three long-bodied, green candles in immediate succession. Each one opens within the body before it and the close is near to the daily high." label.new(bar_index, patternLabelPosLow, text="Three White Soldiers", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishThreeWhiteSoldiers) bgcolor(ta.highest(C_ThreeWhiteSoldiersBullish?1:0, C_ThreeWhiteSoldiersBullishNumberOfCandles)!=0 ? color.new(color.blue, 90) : na, offset=-(C_ThreeWhiteSoldiersBullishNumberOfCandles-1))
- This section includes the code to create an alert condition when the pattern is identified. It also defines the action to add a label on the chart where the pattern occurs and changes the background color to visually highlight the pattern’s presence.
Frequently Asked Questions
The script is designed to detect the “Three White Soldiers” candlestick pattern on financial charts. This pattern is a bullish reversal indicator that appears after a downtrend and is characterized by three consecutive long-bodied bullish (white or green) candles.
The script checks for three consecutive long-bodied, bullish candles. Each candle must open within the body of the previous candle and close higher than the previous close. It also confirms that the candles have small or no upper shadows, which is essential for this pattern.
Yes, traders can modify parameters such as C_Len
, which defines the EMA depth for average body size, and C_ShadowPercent
, which sets the threshold for shadow sizes. These modifications allow the script to be adapted to different trading styles and asset volatility.
bgcolor
Function Do in the Script? The bgcolor
function changes the background color of the chart when the “Three White Soldiers” pattern is detected. This visual cue helps traders quickly identify when the pattern occurs. The color and transparency level can be customized as per user preference.
Yes, the script includes an alertcondition
function that triggers an alert when the “Three White Soldiers” pattern is detected. This feature is useful for traders who want to be promptly notified of potential bullish reversals without constantly monitoring the charts.
Conclusion
The “Three White Soldiers – Bullish” indicator script, crafted for TradingView in Pine Script, efficiently detects the “Three White Soldiers” pattern, a key bullish reversal indicator in financial markets. Characterized by three consecutive long-bodied bullish candles, this pattern suggests a potential shift from a bearish to a bullish trend. Offering customization for different trading approaches, the script includes visual cues and alerts for straightforward pattern identification. It is most effective when combined with other analytical tools, providing a more comprehensive market evaluation and aiding in informed trading strategy development.