Home » Candlestick Patterns » Detecting Falling Three Methods Candlestick Pattern in Pine Script

Detecting Falling Three Methods Candlestick Pattern in Pine Script

Photo of author
Published on

Overview of Falling Three Methods Candlestick Pattern

The “Falling Three Methods” is a bearish continuation candlestick pattern that appears in a downtrend. It consists of five candles and is recognized for its unique structure:

Falling Three Methods Candlestick Pattern
  1. First Candle: This is a long bearish (downward) candle, indicating a strong selling pressure in the downtrend.
  2. Next Three Candles: These are small-bodied, and can be either bullish (upward) or bearish (downward). Importantly, they should be contained within the range of the first candle. These candles represent a temporary pause or consolidation in the market.
  3. Fifth Candle: This is another long bearish candle that closes below the close of the first candle, confirming the resumption of the bearish trend.

The Falling Three Methods pattern is significant because it suggests that, despite a brief consolidation or pause in the market, the overall bearish trend is still strong and likely to continue. Traders often interpret this pattern as an opportunity to join the downtrend, expecting further price declines.

Importance in Technical Analysis

The Falling Three Methods candlestick pattern holds considerable importance in technical analysis due to several reasons:

  1. Confirmation of Trend Continuation: It serves as a reliable indicator of the continuation of an existing downtrend. This can be particularly valuable for traders who are looking to capitalize on sustained downward movements in the market.
  2. Indicative of Market Sentiment: This pattern reflects a brief pause in selling pressure, followed by a strong resumption of the downtrend. It provides insight into market sentiment, suggesting that bearish sentiment remains dominant despite temporary pauses.
  3. Entry and Exit Points: For traders involved in short-selling or looking to exit long positions, the Falling Three Methods pattern can signal opportune moments to enter or exit trades. The completion of the pattern suggests a potential acceleration of the downward trend.
  4. Strengthens Other Technical Indicators: When this pattern appears alongside other bearish indicators or technical patterns (such as moving averages, trendlines, or momentum indicators), it can reinforce the likelihood of a continued downtrend, increasing confidence in trading decisions.
  5. Risk Management: Recognizing this pattern helps in setting appropriate stop-loss orders. Traders might set stop losses above the high of the pattern to manage risk, as a move above this level could invalidate the bearish outlook.

Example From Trading View

Example From Trading View

Defining the Falling Three Methods Candlestick Pattern Criteria 

The Falling Three Methods is a specific candlestick pattern in technical analysis with distinct criteria. Here’s a detailed breakdown of its defining features:

  1. Existing Downtrend: The pattern occurs during a prevailing downtrend. This is crucial as it is a continuation pattern, indicating the persistence of the existing bearish momentum.
  2. First Candle: The pattern starts with a long bearish (downward) candlestick. This candle is an indicator of strong selling pressure and sets the stage for the pattern.
  3. Three Middle Candles: Following the first long bearish candle, there are three smaller, usually bullish or neutral (Doji) candlesticks. These candles should:
    • Open within the body of the previous candle.
    • Close within the body of the first long bearish candle.
    • Be relatively short, indicating a consolidation phase in the market.
    • Not extend beyond the high or low of the first long candle.
  4. Fifth Candle: The final candle in the pattern is another long bearish candle. It should:
    • Break below the closing level of the first candle.
    • Have a body that is nearly equal or larger than the first candle, reinforcing the bearish trend.

Code For Falling Three Methods

//@version=5
indicator("Falling Three Methods - Bearish", shorttitle = "Falling Three Methods", overlay=true)

// Trend determination based on moving averages
C_DownTrend = true
C_UpTrend = true
var trendRule1 = "SMA50"
var trendRule2 = "SMA50, SMA200"
var trendRule = input.string(trendRule1, "Detect Trend Based On", options=[trendRule1, trendRule2, "No detection"])

// Trend detection using single or dual SMA
if trendRule == trendRule1
    priceAvg = ta.sma(close, 50)
    C_DownTrend := close < priceAvg
    C_UpTrend := close > priceAvg

if trendRule == trendRule2
    sma200 = ta.sma(close, 200)
    sma50 = ta.sma(close, 50)
    C_DownTrend := close < sma50 and sma50 < sma200
    C_UpTrend := close > sma50 and sma50 > sma200

// Parameters for candlestick analysis
C_Len = 14 // EMA depth for body average
C_ShadowPercent = 5.0 // Size of shadows as a percentage
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0 // Body size of a Doji as a percentage of the range
C_Factor = 2.0 // Factor for shadow dominance over body

// Calculations for candlestick parts
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

// Positioning for pattern labels
patternLabelPosLow = low - (ta.atr(30) * 0.6)
patternLabelPosHigh = high + (ta.atr(30) * 0.6)

// Input for label color
label_color_bearish = input(color.red, "Label Color Bearish")

// Detection of Falling Three Methods Bearish pattern
C_FallingThreeMethodsBearishNumberOfCandles = 5
C_FallingThreeMethodsBearish = false
if C_DownTrend[4] and (C_LongBody[4] and C_BlackBody[4]) and (C_SmallBody[3] and C_WhiteBody[3] and open[3]>low[4] and close[3]<high[4]) and (C_SmallBody[2] and C_WhiteBody[2] and open[2]>low[4] and close[2]<high[4]) and (C_SmallBody[1] and C_WhiteBody[1] and open[1]>low[4] and close[1]<high[4]) and (C_LongBody and C_BlackBody and close<close[4])
    C_FallingThreeMethodsBearish := true

// Alert condition for the pattern
alertcondition(C_FallingThreeMethodsBearish, title = "New pattern detected", message = "New Falling Three Methods – Bearish pattern detected")

// Label and background color settings when the pattern is detected
if C_FallingThreeMethodsBearish
    var ttBearishFallingThreeMethods = "Falling Three Methods\nFalling Three Methods is a five-candle bearish pattern that signifies a continuation of an existing downtrend. The first candle is long and red, followed by three short green candles with bodies inside the range of the first candle. The last candle is also red and long and it closes below the close of the first candle. This decisive fifth strongly bearish candle hints that bulls could not reverse the prior downtrend and that bears have regained control of the market."
    label.new(bar_index, patternLabelPosHigh, text="Falling Three Methods", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishFallingThreeMethods)
bgcolor(ta.highest(C_FallingThreeMethodsBearish?1:0, C_FallingThreeMethodsBearishNumberOfCandles)!=0 ? color.new(color.red, 90) : na, offset=-(C_FallingThreeMethodsBearishNumberOfCandles-1))

Output

Output

Overview of the script 

1. Script Metadata

//@version=5
indicator("Falling Three Methods - Bearish", shorttitle = "Falling Three Methods", overlay=true)
  • @version=5: Specifies the version of Pine Script used (version 5).
  • indicator(...): Defines the script as a custom indicator with a name and short title.
  • overlay=true: Indicates that the indicator should be overlaid on the price chart.

2. Trend Determination Setup

C_DownTrend = true
C_UpTrend = true
var trendRule1 = "SMA50"
var trendRule2 = "SMA50, SMA200"
var trendRule = input.string(trendRule1, "Detect Trend Based On", options=[trendRule1, trendRule2, "No detection"])
  • This section initializes variables for trend determination and provides input options for the user to select how they want to detect the trend, either using a single 50-period SMA, a combination of 50 and 200-period SMAs, or no trend detection.

3. Trend Detection Logic

// Single SMA trend detection
if trendRule == trendRule1
    priceAvg = ta.sma(close, 50)
    C_DownTrend := close < priceAvg
    C_UpTrend := close > priceAvg

// Dual SMA trend detection
if trendRule == trendRule2
    sma200 = ta.sma(close, 200)
    sma50 = ta.sma(close, 50)
    C_DownTrend := close < sma50 and sma50 < sma200
    C_UpTrend := close > sma50 and sma50 > sma200
  • The script uses either a single 50-period SMA or both 50 and 200-period SMAs to determine the market trend. If the close is below the SMA(s), it’s a downtrend; if above, an uptrend.

4. Initial Parameters

C_Len = 14 // EMA depth for body average
C_ShadowPercent = 5.0 // Size of shadows as a percentage
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0 // Body size of a Doji as a percentage of the range
C_Factor = 2.0 // Factor for shadow dominance over body
  • C_Len: Defines the length for calculating the Exponential Moving Average (EMA) of the candlestick body size.
  • C_ShadowPercent: Determines the minimum size of a shadow (upper or lower) as a percentage of the candle body.
  • C_ShadowEqualsPercent: Used to assess whether the upper and lower shadows are approximately equal in size.
  • C_DojiBodyPercent: Defines what proportion of the total candle range is considered a small enough body to classify as a Doji.
  • C_Factor: A factor indicating how much larger a shadow needs to be compared to the body to be considered dominant.

5. Candlestick Component Calculations

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
  • These lines calculate the high and low of the candle body (C_BodyHi, C_BodyLo), the size of the candle body (C_Body), and the average candle body size (C_BodyAvg). It then determines whether a candle has a small (C_SmallBody) or long (C_LongBody) body compared to the average.

6. Shadow Analysis

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
  • These lines calculate the size of the upper (C_UpShadow) and lower (C_DnShadow) shadows. It then determines whether the candle has a significant upper (C_HasUpShadow) and lower (C_HasDnShadow) shadows based on the C_ShadowPercent parameter.

7. Candlestick Color and Range

C_WhiteBody = open < close
C_BlackBody = open > close
C_Range = high-low
  • Determines the color of the candle (C_WhiteBody for bullish, C_BlackBody for bearish) based on the opening and closing prices, and calculates the total range (C_Range) of the candle.

8. Doji and Inside Bar Identification

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
  • Checks if the current candle is an inside bar relative to the previous candle (C_IsInsideBar), calculates the middle of the candle body (C_BodyMiddle), and assesses if a candle is a Doji (C_Doji). A Doji is identified based on the body size (C_IsDojiBody) and the equality of shadows (C_ShadowEquals).

9. Pattern Detection Logic

C_FallingThreeMethodsBearishNumberOfCandles = 5
C_FallingThreeMethodsBearish = false
if C_DownTrend[4] and (C_LongBody[4] and C_BlackBody[4]) and ...
    C_FallingThreeMethodsBearish := true
  • This is the core logic that identifies the Falling Three Methods pattern. It checks the last five candles to see if they meet the criteria for this bearish pattern, specifically focusing on the trend, candle sizes, colors, and positions.

10. Alert Condition for Pattern Detection

alertcondition(C_FallingThreeMethodsBearish, title = "New pattern detected", message = "New Falling Three Methods – Bearish pattern detected")
  • alertcondition: This function sets up an alert condition in TradingView. When the condition C_FallingThreeMethodsBearish is true (i.e., the Falling Three Methods pattern is detected), it triggers an alert.
  • title and message: These parameters provide a title and a message for the alert. When the pattern is identified, the specified message “New Falling Three Methods – Bearish pattern detected” will be displayed to the user.

11. Label Creation for Pattern Visualization





  • This block of code creates a new label on the chart whenever the Falling Three Methods pattern is detected.
  • label.new: This function adds a new label to the chart.
  • bar_index, patternLabelPosHigh: These parameters determine the position of the label on the chart. It is placed at the high point of the pattern’s range.
  • text="Falling Three Methods": The text displayed in the label.
  • style=label.style_label_down, color = label_color_bearish, textcolor=color.white: These parameters define the style and color of the label.
  • tooltip = ttBearishFallingThreeMethods: The tooltip provides additional information about the pattern when a user hovers over the label.

12. Background Color Highlighting for Pattern

bgcolor(ta.highest(C_FallingThreeMethodsBearish?1:0, C_FallingThreeMethodsBearishNumberOfCandles)!=0 ? color.new(color.red, 90) : na, offset=-(C_FallingThreeMethodsBearishNumberOfCandles-1))
  • This line of code changes the background color of the bars that are part of the Falling Three Methods pattern.
  • bgcolor: This function is used to set the background color of the chart.
  • `ta.highest(C_FallingThreeMethodsBearish?1:0,
  • C_FallingThreeMethodsBearishNumberOfCandles): This expression checks if the Falling Three Methods pattern is present within the last
  • C_FallingThreeMethodsBearishNumberOfCandles(which is set to 5). If the pattern is detected, it returns1; otherwise, 0`.
  • color.new(color.red, 90): Specifies the color and transparency for the background. In this case, it’s a semi-transparent red color.
  • na: This is used as a fallback value. If the pattern is not detected, no background color is applied.
  • offset=-(C_FallingThreeMethodsBearishNumberOfCandles-1): The offset parameter shifts the background coloring to align with the bars where the pattern occurs.

Frequently Asked Questions

What is the Falling Three Methods Pine Script designed for?

It’s a custom TradingView indicator to identify the Falling Three Methods candlestick pattern in a price chart, signaling a bearish continuation in a downtrend.

How does the script determine the market trend?

The script uses Simple Moving Averages (SMA). Users can choose between a single 50-period SMA or a dual setup with 50 and 200-period SMAs to define the trend.

What are the key components of the Falling Three Methods pattern in this script?

The pattern consists of five candles: a long bearish candle, followed by three smaller bullish or neutral candles, and another long bearish candle.

Does the script provide visual indicators for the pattern?

Yes, it highlights the pattern by changing the background color of the bars involved and adds a label on the chart for easy identification.

Can the script send alerts for pattern detection?

Absolutely. It generates alerts when the Falling Three Methods pattern is detected, assisting in timely decision-making.

Conclusion

The Pine Script for the Falling Three Methods pattern offers a technical indicator specifically tailored to identify this bearish continuation pattern. It employs moving averages to determine market trends and accurately marks the pattern on the chart using visual cues like labels and background color changes. Additionally, it provides timely alerts, enhancing the decision-making process for traders. However, it’s important to remember that no single indicator should be used in isolation. The effectiveness of the Falling Three Methods pattern script is enhanced when combined with other technical analysis tools and methods. Traders should also consider market context, other technical indicators, and their trading strategies to make informed decisions.

Leave a Comment