Home » Candlestick Patterns » Detecting Rising Window Candlestick Pattern in Pine Script

Detecting Rising Window Candlestick Pattern in Pine Script

Photo of author
Published on

Overview of Rising Window Candlestick Pattern

The Rising Window candlestick pattern is a bullish indicator in technical analysis, often observed in stock and other financial markets. It is characterized by a specific formation of candlesticks, indicating a continuation of an uptrend. Here’s an overview of its features and implications:

Rising Window Candlestick Pattern
  1. Formation and Structure: The Rising Window consists of two consecutive candlesticks with a gap between them. This gap is formed because the low price of the second candle is higher than the high price of the first candle, creating a “window” or empty space on the chart.
  2. Market Context: It typically appears during an uptrend and is considered a strong bullish signal. The pattern suggests an intensification of buying pressure.
  3. Components of the Pattern:
    • First Candle: Can be either bullish or bearish, but it is typically followed by a gap up.
    • Second Candle: Opens at a higher level than the first candle’s close, with no overlap in their price ranges.

Importance in Technical Analysis

In technical analysis, the Rising Window candlestick pattern holds significant importance due to several key reasons:

  1. Bullish Continuation Signal: The Rising Window is primarily regarded as a bullish continuation pattern. It indicates that the current uptrend is expected to continue, making it a crucial signal for traders and investors who follow trend-based strategies.
  2. Psychological Insight: This pattern demonstrates strong buying pressure and bullish sentiment in the market. The gap represents a level where no sellers were willing to sell, reflecting eagerness among buyers to acquire the asset, even at higher prices.
  3. Enhanced Probability of Trend Continuation: When this pattern appears during an uptrend, it reinforces the likelihood of the continuation of the bullish trend. This can be particularly useful for traders in deciding whether to enter new positions or hold existing ones.
  4. Volume Confirmation: The pattern’s significance is often validated by accompanying high trading volumes. Increased volume during the pattern formation implies a stronger consensus among market participants about the bullish direction.
  5. Strategic Trading Decisions: The Rising Window can serve as an indicator for traders to consider initiating or adding to long positions. It provides a clear visual cue for potential entry points in an uptrend.

Example From Trading View

Example From Trading View

Defining the Rising Window Candlestick Pattern Criteria 


The Rising Window candlestick pattern is defined by specific criteria in technical analysis, primarily signaling a continuation of a bullish trend. Here are the key criteria for identifying this pattern:

  1. Prevailing Uptrend: The pattern should occur within an existing uptrend. Its presence during an uptrend enhances its significance as an indicator of bullish trend continuation.
  2. First Candle Characteristics:
    • The first candle can be either bullish or bearish, but it typically forms part of an upward price movement. The actual direction of this candle is less crucial than the gap that follows.
  3. Price Gap:
    • A critical feature of the Rising 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 higher than the high of the first candle, creating a visible gap on the chart.
  4. Second Candle Features:
    • The second candle should continue the bullish trend. It does not necessarily have to close higher than its open, but its opening above the first candle’s high is vital.

Code For Detecting Rising Window

//@version=5
indicator("Rising Window - Bullish", shorttitle = "Rising Window - Bullish", 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_bullish = input(color.blue, "Label Color Bullish")
C_RisingWindowBullishNumberOfCandles = 2
C_RisingWindowBullish = false
if C_UpTrend[1] and (C_Range!=0 and C_Range[1]!=0) and low > high[1]
	C_RisingWindowBullish := true
alertcondition(C_RisingWindowBullish, title = "New pattern detected", message = "New Rising Window – Bullish pattern detected")
if C_RisingWindowBullish
    var ttBullishRisingWindow = "Rising Window\nRising Window is a two-candle bullish continuation pattern that forms during an uptrend. 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 high and the second candle's low. That gap (window) between two bars signifies support against the selling pressure."
    label.new(bar_index, patternLabelPosLow, text="Rising Window", style=label.style_label_up, color = color.green, textcolor=color.rgb(0, 0, 0), tooltip = ttBullishRisingWindow)
bgcolor(ta.highest(C_RisingWindowBullish?1:0, C_RisingWindowBullishNumberOfCandles)!=0 ? color.new(#46ff2d, 90) : na, offset=-(C_RisingWindowBullishNumberOfCandles-1))

Output

Output

Overview of the script 

Script Initialization

//@version=5
indicator("Rising Window - Bullish", shorttitle = "Rising Window - Bullish", overlay=true)
  • Sets Pine Script version to 5.
  • Declares a new indicator named “Rising Window – Bullish” with a short title.
  • overlay=true makes the indicator appear directly on the price chart.

Trend Detection Variables and User Input

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 trend direction variables.
  • Defines user input options for trend detection based on Simple Moving Averages (SMA).

Trend Calculation Based on User Selection

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 conditions set the trend direction based on the selected SMA criteria. For trendRule1, it uses SMA50; for trendRule2, it compares both SMA50 and SMA200.

Candlestick Feature Analysis

C_BodyHi = math.max(close, open) // Calculates the highest point of the candle's body
C_BodyLo = math.min(close, open) // Calculates the lowest point of the candle's body
C_Body = C_BodyHi - C_BodyLo // Determines the size of the candle's body
C_BodyAvg = ta.ema(C_Body, C_Len) // Average size of the candle's body over a specified length
C_SmallBody = C_Body < C_BodyAvg // True if the body is smaller than the average
C_LongBody = C_Body > C_BodyAvg // True if the body is larger than the average
C_UpShadow = high - C_BodyHi // Size of the upper shadow (wick)
C_DnShadow = C_BodyLo - low // Size of the lower shadow (wick)
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body // True if the upper shadow is significant
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body // True if the lower shadow is significant
C_WhiteBody = open < close // True if the candle is bullish (white body)
C_BlackBody = open > close // True if the candle is bearish (black body)
C_Range = high-low // Total range of the candle including wicks
  • The script sets up variables to analyze various features of the candlesticks, including the body high and low, the presence and size of shadows, and body sizes relative to an average (calculated using EMA).

Special Candlestick Formations

C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo // True if the current candle is an inside bar
C_BodyMiddle = C_Body / 2 + C_BodyLo // Middle point of the candle's body
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 // Checks if the upper and lower shadows are approximately equal
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 // Identifies if the candle has a very small body (doji)
C_Doji = C_IsDojiBody and C_ShadowEquals // Determines if a candle is a doji
  • The script uses the variables set up in Step 4 to identify specific candlestick formations like doji candles and inside bars.
  • Doji candles (C_Doji) are identified based on a small body (C_IsDojiBody) and approximately equal upper and lower shadows (C_ShadowEquals).
  • Inside bars (C_IsInsideBar) are identified based on the current candle’s high and low being within the range of the previous candle’s high and low.

Pattern Detection Logic

C_RisingWindowBullish = false
if C_UpTrend[1] and (C_Range!=0 and C_Range[1]!=0) and low > high[1]
    C_RisingWindowBullish := true
  • Sets the main logic for detecting the Rising Window pattern. It checks if the previous candle was in an uptrend, ensures the current and previous candles are not doji, and verifies the gap up between the current low and the previous high.

Pattern Alert and Labeling

alertcondition(C_RisingWindowBullish, title = "New pattern detected", message = "New Rising Window – Bullish pattern detected")
if C_RisingWindowBullish
    var ttBullishRisingWindow = "Rising Window\nRising Window is a two-candle bullish continuation pattern that forms during an uptrend. 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 high and the second candle's low. That gap (window) between two bars signifies support against the selling pressure."
    label.new(bar_index, patternLabelPosLow, text="Rising Window", style=label.style_label_up, color = color.green, textcolor=color.rgb(0, 0, 0), tooltip = ttBullishRisingWindow)
  • Sets an alert condition when the Rising Window pattern is detected.
  • Adds a new label to the chart where the pattern occurs, providing visual identification.

Background Coloring

bgcolor(ta.highest(C_RisingWindowBullish?1:0, C_RisingWindowBullishNumberOfCandles)!=0 ? color.new(#46ff2d, 90) : na, offset=-(C_RisingWindowBullishNumberOfCandles-1))
  • Changes the background color of the bars where the pattern is found, making it easier to spot on the chart.

Frequently Asked Questions

What does the “Rising Window – Bullish” script identify?

This script identifies the Rising Window candlestick pattern, a bullish continuation signal in an uptrend.

How does the script determine the market trend?

It uses Simple Moving Averages (SMA50 or SMA50 and SMA200) to assess the market trend, based on user-selected criteria.

What are the key features analyzed in the script for pattern detection?

The script analyzes candlestick body size, upper and lower shadows, doji formations, and inside bar patterns.

Can I adjust the trend detection settings in the script?

Yes, the script includes user inputs to choose between SMA50, SMA50 and SMA200, or no trend detection for flexibility.

Does this script provide visual indicators on the chart?

Yes, it labels detected Rising Window patterns on the chart and changes the background color for easy recognition.

Conclusion

This script is designed to detect the Rising Window candlestick pattern, providing traders with a powerful tool to identify bullish continuation signals in the market. Its combination of technical analysis and user-friendly features makes it a valuable asset for enhancing trading strategies. By analyzing key candlestick features and offering customizable trend detection settings, it provides a practical way to spot Rising Window patterns, aiding in informed trading decisions. Its visual indicators on the chart further enhance its utility, making it a useful addition to a trader’s technical analysis toolkit.

Leave a Comment