Overview of Three Inside Up Candlestick Pattern
The Three Inside Up candlestick pattern is a bullish reversal pattern found in technical analysis of financial markets. It signifies a potential shift from a bearish to a bullish market sentiment and is composed of three specific candlesticks:
- First Candle: This is a large bearish candle that continues the current downtrend.
- Second Candle: A smaller bullish candle that is completely contained within the range of the first candle. Its presence suggests a weakening of the ongoing bearish trend.
- Third Candle: Another bullish candle that closes above the close of the second candle, indicating a potential reversal of the bearish trend.
This pattern typically emerges at the end of a downtrend and is considered a reliable indicator of a bullish reversal. Traders often use it to identify potential buying opportunities, expecting the price to move higher. However, it is advisable to consider additional technical indicators and market factors for confirmation, as relying solely on this pattern may not always yield accurate predictions.
Importance in Technical Analysis
In technical analysis, the Three Inside Up candlestick pattern holds significant importance for several reasons:
- Reversal Signal: It is primarily valued as a bullish reversal signal. Appearing at the end of a downtrend, it suggests a potential shift in market momentum from bearish to bullish, indicating that the selling pressure is diminishing and buyers are starting to take control.
- Confirmation of Trend Change: The pattern provides a more reliable confirmation of a trend change compared to single-candle patterns. Its three-candle structure requires confirmation over multiple trading periods, reducing the likelihood of a false signal.
- Risk Management: It aids traders in setting clear entry, stop-loss, and take-profit points. The third candle’s close can serve as an entry point, while the low of the pattern can be a logical place for a stop-loss order.
- Complements Other Indicators: The Three Inside Up pattern works best when combined with other technical analysis tools, such as moving averages, oscillators, or support and resistance levels, to validate the signal and enhance decision-making.
- Psychological Insight: This pattern reflects a change in investor sentiment, offering insight into the psychology of market participants. The initial bearish sentiment is countered by increasing bullish momentum, indicative of changing market dynamics.
Example From Trading View
Defining the Three Inside Up Candlestick Pattern Criteria
The Three Inside Up candlestick pattern is defined by specific criteria that signal a potential bullish reversal in a downtrend. These criteria are:
- Downtrend Precedence: The pattern should occur during a clear downtrend in the market. This establishes the context for a potential reversal.
- First Candle – Large Bearish Candle: The first candle of the pattern must be a large bearish (down) candle. Its size and bearish nature confirm the existing downtrend.
- Second Candle – Smaller Bullish Candle: The second candle should be a smaller bullish (up) candle. Crucially, this candle must be entirely contained within the vertical range of the first candle (including the body and the wicks). This suggests a weakening of the bearish sentiment.
- Third Candle – Bullish Close Above Second Candle: The third candle must be another bullish candle that closes above the close of the second candle. This is the key confirmation of the pattern, indicating a shift in momentum and a potential reversal of the trend.
Code For Detecting Three Inside Up
//@version=5 indicator("Three inside candles", shorttitle="Three inside", overlay=true) // Input for the Exponential Moving Average (EMA) period ema_input = input.int(15, title="Ema", minval=5, maxval=50) // Calculation of the EMA using the user-defined period prev_p_1 = ta.ema(close, ema_input) // Plotting the EMA on the chart with yellow color plot(prev_p_1, color = color.yellow) // Calculation of minimum and maximum values of the current bar's open and close open_close_min = math.min(close, open) open_close_max = math.max(close, open) // Calculating the range (bar) of the current bar bar = open_close_max - open_close_min // Accessing the previous bar's close and open values close_1 = close[1] open_1 = open[1] // Calculating the minimum and maximum of the previous bar's open and close open_close_min_1 = math.min(close[1], open[1]) open_close_max_1 = math.max(close[1], open[1]) // Calculating the range (bar) of the previous bar bar_1 = open_close_max_1 - open_close_min_1 // Accessing the close and open values of the bar before the previous one close_2 = close[2] open_2 = open[2] // Calculating the minimum and maximum of the bar before the previous one's open and close open_close_min_2 = math.min(close[2], open[2]) open_close_max_2 = math.max(close[2], open[2]) // Calculating the range (bar) of the bar before the previous one bar_2 = open_close_max_2 - open_close_min_2 // Logic to identify the 'Three Inside Up' pattern triple_inside_up = open_close_min_2 == open_close_min_1 and bar_1 > bar_2 * 0.4 and bar_1 < bar_2 * 0.6 and close > open_2 and bar > bar_1 and bar + bar_1 < bar_2 * 2 // Plotting an upward arrow below the bar if the 'Three Inside Up' pattern is identified plotshape(triple_inside_up ? 1 : na, style=shape.arrowup, color=color.rgb(0, 255, 8), location=location.belowbar, size=size.large, text="Three inside up")
Output
Overview of the script
1. Script Declaration and Setup
//@version=5 indicator("Three inside candles", shorttitle="Three inside", overlay=true)
//@version=5
: Specifies that this script uses version 5 of Pine Script.indicator
: Declares that this script is an indicator."Three inside candles"
: The full name of the indicator.shorttitle="Three inside"
: A shorter title for the indicator.overlay=true
: This ensures that the indicator is overlaid on the price chart.
2. Input for Exponential Moving Average (EMA)
ema_input = input.int(15, title="Ema", minval=5, maxval=50)
input.int
: This function creates an input for the user to select an integer value.15
: The default value for the EMA period.title="Ema"
: The title for the input field in the indicator settings.minval=5
andmaxval=50
: Sets the minimum and maximum values that the user can select for the EMA period.
3. Calculation and Plotting of EMA
prev_p_1 = ta.ema(close, ema_input) plot(prev_p_1, color = color.yellow)
prev_p_1 = ta.ema(close, ema_input)
: Calculates the Exponential Moving Average of theclose
prices of bars for the period specified byema_input
.plot(prev_p_1, color = color.yellow)
: Plots the calculated EMA on the chart with a yellow color.
4. Calculation of Minimum and Maximum Values for the Current Bar
open_close_min = math.min(close, open) open_close_max = math.max(close, open)
open_close_min
: Calculates the minimum of theopen
andclose
price of the current bar.open_close_max
: Calculates the maximum of theopen
andclose
price of the current bar.
5. Calculation of the Current Bar Range
bar = open_close_max - open_close_min
bar
: Computes the range (difference) between the maximum and minimum values of the current bar.
6. Accessing Previous Bar Values
close_1 = close[1] open_1 = open[1] open_close_min_1 = math.min(close[1], open[1]) open_close_max_1 = math.max(close[1], open[1]) bar_1 = open_close_max_1 - open_close_min_1
close[1]
andopen[1]
: Retrieves theclose
andopen
prices of the previous bar.open_close_min_1
andopen_close_max_1
: Calculates the min and max of the previous bar’sopen
andclose
prices.bar_1
: Computes the range of the previous bar.
7. Accessing Values from Two Bars Ago
close_2 = close[2] open_2 = open[2] open_close_min_2 = math.min(close[2], open[2]) open_close_max_2 = math.max(close[2], open[2]) bar_2 = open_close_max_2 - open_close_min_2
- Similar to step 6, but for the bar two periods ago.
8. Three Inside Up Pattern Identification
triple_inside_up = open_close_min_2 == open_close_min_1 and bar_1 > bar_2 * 0.4 and bar_1 < bar_2 * 0.6 and close > open_2 and bar > bar_1 and bar + bar_1 < bar_2 * 2
- This line of code implements the logic for identifying the ‘Three Inside Up’ pattern, based on the relationships between the current bar, the previous bar, and the bar before that.
9. Plotting the Pattern Recognition
plotshape(triple_inside_up ? 1 : na, style=shape.arrowup, color=color.rgb(0, 255, 8), location=location.belowbar, size=size.large, text="Three inside up")
plotshape
: This function plots a shape on the chart.triple_inside_up ? 1 : na
: If thetriple_inside_up
the pattern is identified, it plots a shape; otherwise, it plots nothing.style=shape.arrowup
: The shape of the plot is an upward arrow.color=color.rgb(0, 255, 8)
: The color of the arrow is set to a shade of green.location=location.belowbar
: The arrow is plotted below the bar.size=size.large
: The size of the arrow is large.text="Three inside up"
: Text label for the shape.
Frequently Asked Questions
The “Three Inside Up” indicator is designed to identify a specific bullish reversal candlestick pattern in a financial chart. This pattern is characterized by a sequence of three candles, suggesting a potential shift from a bearish to a bullish trend.
The script calculates an Exponential Moving Average (EMA) based on a user-defined period (default is 15). The EMA is plotted on the chart to help users visualize the trend and potentially confirm the signals given by the “Three Inside Up” pattern.
Yes, the EMA period can be adjusted. The script includes an input field (ema_input
) that allows users to select any integer value between 5 and 50 as the period for the EMA calculation.
The script identifies the “Three Inside Up” pattern based on specific criteria involving the last three candles on the chart. It checks the sizes and positions of these candles about each other to confirm if the pattern matches the classic “Three Inside Up” formation.
Yes, the script can be used across various financial markets including stocks, forex, commodities, and others. However, the effectiveness of candlestick patterns like the “Three Inside Up” can vary between markets and different timeframes, so it’s advisable to use it in conjunction with other technical analysis tools and methods.
Conclusion
This script detects the “Three Inside Up” candlestick pattern, a significant indicator in technical analysis signaling a potential bullish reversal in a downtrend. It does so by meticulously analyzing the relationships between consecutive candlesticks on a chart. Additionally, the inclusion of an Exponential Moving Average (EMA) provides a broader context of the prevailing market trend, aiding in the confirmation of the pattern’s validity. While the script is a powerful tool for pattern recognition, it’s important to remember that no technical analysis method is infallible. The effectiveness of the “Three Inside Up” pattern can vary across different markets and timeframes. Therefore, traders and investors should use this script in conjunction with other technical indicators and fundamental analysis to make more informed trading decisions. The script’s flexibility, allowing users to adjust the EMA period, further enhances its utility across various trading strategies and market conditions.