Overview of Falling Window Candlestick Pattern
The Falling Window candlestick pattern is a significant formation in technical analysis, typically indicating a continuation of a bearish trend. It is particularly observed in stock and financial market charts. Here’s a brief overview of its characteristics and implications:
- Formation: This pattern is identified by a gap between two consecutive candlesticks. The gap occurs when the low price of the second candle is lower than the high price of the first candle, creating a “window” or empty space on the chart.
- Context: The Falling Window usually appears during a downtrend and is considered a bearish signal. It suggests an intensification of selling pressure.
- Components:
- First Candle: Can be either bullish or bearish but is typically followed by a gap down.
- Second Candle: Opens at a lower level than the first candle’s close, with no overlap in their price ranges.
Importance in Technical Analysis
In technical analysis, the Falling Window candlestick pattern holds significant importance for several reasons:
- Bearish Continuation Signal: The Falling Window is a bearish continuation pattern. It is typically interpreted as an indication that the current downtrend is likely to continue, providing valuable information for traders looking to take advantage of the prevailing trend.
- Psychological Insight: This pattern provides insight into market sentiment. The gap down indicates a strong bearish sentiment, suggesting that sellers are in control and buyers are not stepping in to fill the gap, reinforcing the negative outlook.
- Increased Probability of Trend Continuation: In a downtrend, the appearance of a Falling Window increases the likelihood of the continuation of the bearish trend. This can be particularly useful for traders who rely on trend-following strategies.
- Volume Confirmation: When accompanied by high trading volumes, the reliability of the Falling Window as a bearish signal is enhanced. High volume indicates a consensus among market participants about the downward direction of the market.
- Strategic Entry and Exit Points: For traders, the Falling Window can serve as a signal to initiate or add to short positions or to exit long positions. It provides a clear visual cue for potential entry and exit points in a downtrend.
Example From Trading View
Defining the Falling Window Candlestick Pattern Criteria
The Falling Window candlestick pattern is defined by specific criteria in technical analysis, which signal a continuation of a bearish trend. Here are the key criteria for identifying this pattern:
- Prevailing Downtrend: The Falling Window typically appears within a downtrend. Its presence in an ongoing bearish market context enhances its significance as a continuation pattern.
- First Candle Characteristics:
- The first candle can be either bullish or bearish, but it is often part of a downward price movement. The actual direction of this candle is less significant than the gap that follows.
- Price Gap:
- The essential feature of the Falling Window is the gap between two consecutive candlesticks. There should be no overlap in the trading range (high and low prices) of these candles.
- The second candle opens significantly lower than the low of the first candle, creating a visible gap on the chart.
- Second Candle Features:
- The second candle continues the bearish trend. It doesn’t necessarily need to close lower than its open, but its opening below the first candle’s low is crucial.
Code For Detecting Falling Window
//@version=5 indicator("Falling Window - Bearish", shorttitle = "Falling Window - Bear", overlay=true) 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"]) 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 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_bearish = input(color.red, "Label Color Bearish") C_FallingWindowBearishNumberOfCandles = 2 C_FallingWindowBearish = false if C_DownTrend[1] and (C_Range!=0 and C_Range[1]!=0) and high < low[1] C_FallingWindowBearish := true alertcondition(C_FallingWindowBearish, title = "New pattern detected", message = "New Falling Window – Bearish pattern detected") if C_FallingWindowBearish var ttBearishFallingWindow = "Falling Window\nFalling Window is a two-candle bearish continuation pattern that forms during a downtrend. Both candles in the pattern can be of any type, with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle's low and the second candle's high. The existence of this gap (window) means that the bearish trend is expected to continue." label.new(bar_index, patternLabelPosHigh, text="Falling Window", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishFallingWindow) bgcolor(ta.highest(C_FallingWindowBearish?1:0, C_FallingWindowBearishNumberOfCandles)!=0 ? color.new(color.red, 90) : na, offset=-(C_FallingWindowBearishNumberOfCandles-1))
Output
Overview of the script
1. Script Initialization
//@version=5 indicator("Falling Window - Bearish", shorttitle = "Falling Window - Bear", overlay=true)
- Sets the version of Pine Script being used to version 5.
- Declares a new indicator named “Falling Window – Bearish” with a short title for display purposes.
overlay=true
indicates that this indicator will be overlaid on the main price chart.
2. Trend Detection 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"])
- Initializes variables
C_DownTrend
andC_UpTrend
totrue
. These will be used to determine the current market trend. - Sets up user input for selecting the trend detection rule. The options are based on Simple Moving Averages (SMA) – either SMA50, SMA50 and SMA200 combined, or no trend detection.
3. Trend Calculation Logic
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
- These blocks contain logic to calculate the trend based on the selected rule. If the rule is SMA50, it compares the close price with SMA50. If the rule is SMA50 and SMA200, it compares the close price with both SMA50 and SMA200.
4. Candlestick Analysis Setup
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
- Candlestick Body Analysis:
C_BodyHi
andC_BodyLo
calculate the high and low of the candle’s body (ignoring the wicks).C_Body
computes the size of the candle’s body.C_BodyAvg
calculates the average size of the candle’s body over a specified length (C_Len
), using an Exponential Moving Average (EMA).C_SmallBody
andC_LongBody
are boolean variables that determine whether the candle’s body is smaller or larger than the average.
- Shadow Analysis:
C_UpShadow
andC_DnShadow
calculate the size of the upper and lower shadows (wicks) of the candle.C_HasUpShadow
andC_HasDnShadow
determine whether the upper and lower shadows are significantly large (more than a specified percentage of the candle’s body).
- Candlestick Type Determination:
C_WhiteBody
andC_BlackBody
identify whether the candle is bullish (white) or bearish (black).C_Range
calculates the total range of the candle, including wicks.
- Special Candlestick Formations:
C_IsInsideBar
checks if the current candle is an inside bar (completely within the range of the previous candle).C_BodyMiddle
calculates the middle point of the candle’s body.C_ShadowEquals
checks if the upper and lower shadows are approximately equal in size.C_IsDojiBody
identifies if the candle is a doji, characterized by a very small body.C_Doji
determines if a candle is a doji by combining the body and shadow criteria.
5. Pattern Detection Logic
C_FallingWindowBearish = false if C_DownTrend[1] and (C_Range!=0 and C_Range[1]!=0) and high < low[1] C_FallingWindowBearish := true
- Sets up the main logic for detecting the Falling Window pattern. It checks if the previous candle was in a downtrend, ensures that the current and previous candles are not doji (having a non-zero range), and that there is a gap between the current high and the previous low.
6. Pattern Alert and Visualization
alertcondition(C_FallingWindowBearish, title = "New pattern detected", message = "New Falling Window – Bearish pattern detected") if C_FallingWindowBearish var ttBearishFallingWindow = "Falling Window\nFalling Window is a two-candle bearish continuation pattern that forms during a downtrend. Both candles in the pattern can be of any type, with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle's low and the second candle's high. The existence of this gap (window) means that the bearish trend is expected to continue." label.new(bar_index, patternLabelPosHigh, text="Falling Window", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishFallingWindow) bgcolor(ta.highest(C_FallingWindowBearish?1:0, C_FallingWindowBearishNumberOfCandles)!=0 ? color.new(color.red, 90) : na, offset=-(C_FallingWindowBearishNumberOfCandles-1)) break down this code and explain the each step in detail
- Sets an alert condition when the Falling Window pattern is detected.
- Creates a new label on the chart to visually indicate where the pattern has occurred.
- Changes the background color of the bars where the pattern is found, making it easier to spot.
Frequently Asked Questions
This script identifies the “Falling Window” bearish continuation pattern in financial market charts.
It uses Simple Moving Averages (SMA50 alone or SMA50 and SMA200 combined) to assess the market trend, based on user selection.
The script analyzes candlestick body size, upper and lower shadows, the presence of doji candles, and inside bars.
Yes, users can select between different SMA-based trend detection methods or opt for no trend detection.
Yes, it marks detected patterns with labels and changes the background color of the bars where the pattern occurs.
Conclusion
The Pine Script code we’ve discussed identifies the “Falling Window” pattern in market charts. By analyzing candlestick features and incorporating user-defined trend analysis methods, it offers a customizable approach to spotting bearish continuation signals. The script’s visual cues and alerts further enhance its utility, making it a valuable addition to a trader’s technical analysis toolkit. However, it’s important to remember that this tool, like any technical indicator, should ideally be used in conjunction with other analysis methods for more comprehensive market insights.