PROTECTED SOURCE SCRIPT

Advanced Candlestick Patterns [vitruvius]

This is a very advanced indicator that detects most commonly used candlestick patterns. Please read this document carefully to understand how it works.

It is tailored to identify patterns that only have a great possibility of signaling a price movement. In other words, it can and will ignore some patterns, even though they satisfy the recognition conditions defined in the books. Candlestick patterns should also satisfy some other conditions in this indicator to be valid and you can modify those conditions.

This indicator is not only about identifying the candlestick patterns. By using the different choices, you can:
  • Avoid fake signals
  • Confirm patterns
  • Increase your possibility to win a trade
  • Reduce risk
  • Identify bullish/bearish movements better


Recommended Use
This indicator works best when you:
  • Use it in the daily time frame
  • Combine it with Support/Resistance areas


Note: For some candlestick patterns, you have the option of confirming the pattern with the next price action. In those cases, there will be obviously one bar delay (because it will wait for one more bar to close to confirm the pattern). However, it will mark the candlestick where it identifies the pattern and it will have ”Confirmed” in its text.

Important Note
This indicator does some serious calculations and checks for a lot of user inputs. Therefore, it might be a little slow. Please give it some time when it needs to do some computing.


MODULES

Trend Detection
Most of the patterns in this script are trend reversal patterns. So, recognition of the candlestick patterns depends heavily on the trend. In fact, even if you do not select a trend detection method, it will use the SMA method as default where it needs a certain trend in identifying a specific pattern.

It is possible to combine multiple trend detection methods. You can see how this affects the overall trend detection by enabling the background coloring.

Note: There might be some cases where a candle has a bullish/bearish confirmation of the same candlestick pattern. In those cases, the script is unable to identify the move and the user should decide if the identified pattern is bullish or bearish.

Below are the inputs of this module:
  • Color the background according to the trend?
    If you select a trend detection method, it will color the background green for an uptrend and red for a downtrend.
  • Counter the trend when there is no obvious trend?
    If you select multiple trend detection methods, there might be some cases where one of the methods indicates an uptrend and the other one indicates a downtrend. In that case, the script will continue with the previous trend (whatever the trend is one bar ago) by default. You can, however, reverse the trend in those cases by using this option. If you choose to reverse, you might catch the trend early.
  • Use MACD to detect the trend?
    Use MACD to detect the trend. Whenever MACD delta is greater or equal to zero, it is an uptrend.
  • MACD Fast Length
    Fast length of MACD.
  • MACD Slow Length
    Slow length of MACD.
  • MACD Signal Smoothing
    Signal smoothing value of MACD. Please note that it is set to 6 by default.
  • Use SMA to detect the trend?
    Use SMA to detect the trend. If the price closes above the SMA line, it is an uptrend
  • SMA Length
    Length of SMA.
  • Use the average price of previous candles to detect the trend?
    If the average of open and close prices constantly go up for n bars that are determined by the next user input, it is an uptrend.
  • Number of candles to analyze
    The number of bars (n) to analyze for the average price method.
  • Use the closing price of the previous candle to detect the trend?
    If the difference between the current close and nth previous bar’s close is greater than the given threshold, it is an uptrend.
  • Position of the previous candle to analyze
    Position of the bar (backward) to compare with the current close price.
  • Threshold for the closing price
    The threshold value for closing price method.


Basic Candlestick Patterns
This module detects Doji, Spinning Top, Marubozu candlestick patterns. Also, you can set some specific options that are going to be used in all candlestick patterns.

Note: If you choose to manually enter the body height of a doji, you need to find the optimal value for different timeframes. Different timeframes have difference price action ranges.

Below are the inputs of this module:
  • Tolerate opening/closing price of the candle?
    When a candlestick pattern needs to have a gap between two candles, you can tolerate the opening/closing prices of the one candle. This option is useful where the opening and closing prices are very close. This option is going to be used in all candlestick patterns.
  • Factor for tolerating opening/closing price
    The more the factor is, the more the tolerance is.
  • Body/Height ratio for a candle to be considered as Bullish/Bearish
    A bullish/bearish candle shouldn’t have too much shadow. You can use this option to determine the shadow length of a bullish/bearish bar. This option is going to be used in all candlestick patterns
  • Use basic candlestick pattern (Doji, Spinning Top, Marubozu)?
    Detect doji, spinning top, marubozu candlestick patterns.
  • Manually set body of Doji?
    You can manually set the body height of a doji. Otherwise, it will be calculated automatically. If you choose to use this option, then spinning top, and marubozu will also be calculated based on this.
  • Body of Doji
    Body height of a bar to be considered as doji. Any bar with a body equal or less than the given value will be marked as doji. Only effective if you check the ”Manually set body of Doji?” option.
  • Verify a Doji by looking at the preceding candle?
    If true, it will only mark dojis if the preceding candle is bullish or bearish.


Single Candlestick Patterns
This module detects Hammer, Hanging Man, Inverted Hammer, Shooting Star single candlestick patterns.

Below are the inputs of this module:
  • Confirm Single Candlestick Patterns with next closing price?
    You can confirm a single candlestick pattern with the next closing price. That is, if the next candle closes above the previous one, it will confirm a bullish movement. If the next candle closes below the previous one, it will confirm a bearish movement.
  • Use Hammer and Hanging Man Single Candlestick Patterns?
    Detect hammer and hanging man single candlestick patterns.
  • Use Inverted Hammer and Shooting Star Single Candlestick Patterns?
    Detect inverted hammer and shooting star single candlestick patterns.


Dual Candlestick Patterns
This module detects Engulfing, Tweezer Bottoms, Tweezer Tops, Harami, Inside Bar, Piercing Line, Dark Cloud Cover dual candlestick patterns.

Below are the inputs of this module:
  • Use Engulfing Dual Candlestick Pattern?
    Detect engulfing dual candlestick pattern.
  • Validate Engulfing by comparing highs and lows?
    If checked, the second bar must engulf the previous bar’s high/low also. If unchecked, the second bar should only engulf the real body of the first bar.
  • Use Tweezer Bottoms and Tops Dual Candlestick Patterns?
    Detect tweezer bottoms and tweezer tops dual candlestick patterns.
  • Check the shadow equality of Tweezer Bottom and Tops?
    Check if the shadows of the tweezer bars are about the same length.
  • Detect Harami Dual Candlestick Pattern?
    Detect harami dual candlestick pattern.
  • Use High/Low of the second Harami candle instead of Open/Close price?
    If checked, the body of the child must be within High and Low of the mother bar. Otherwise, only open/close prices will be checked.
  • Detect Inside Bar Dual Candlestick Pattern?
    Detect inside bar dual candlestick pattern.
  • Treat Inside Bar as a reversal pattern?
    If checked, inside bar will be treated as a bullish/bearish reversal pattern.
  • Check if the Inside bar formed in the upper/lower half of the Mother bar?
    Check if the inside bar forms within the upper/lower body half of the mother. Then it will be treated as a bullish/bearish inside bar.
  • Detect the Inside Bar only if the previous candle closes outside of the Keltner channel?
    This option effects identifying the inside bar. Such that, an inside bar will be detected only if the previous candle closes outside of Keltner Channel. Inside bars are effective when the market is extended and this is a nice way to check for that.
  • Confirm Inside Bar with the next close breaching the low/high of the inside bar?
    Check if the next bar breaches inside bar’s high/low. Then it will be treated as a bullish/bearish inside bar.
  • Use Piercing Line and Dark Cloud Cover Dual Candlestick Patterns?
    Detect Piercing Line and Dark Cloud Cover dual candlestick patterns.


Triple Candlestick Patterns
This module detects Morning Star, Evening Star, Three White Soldiers, Three Black Crows, Three Inside Up, Three Inside Down, Three Line Strike, Abandoned Baby, NR4, NR7 candlestick patterns.

Below are the inputs of this module:
  • Use Morning and Evening Star Triple Candlestick Pattern?
    Detect morning and evening star triple candlestick patterns.
  • Don't allow the second candle's body to overlap with the first and third candle?
    If checked, high and low of the second candle cannot overlap with the first and third candle for morning and evening star candlestick patterns.
  • The third candle must close beyond the midpoint of the first candle?
    If checked, the third candle must close beyond the midpoint of the first candle for morning and evening star candlestick patterns.
  • Use Three White Soldiers and Three Black Crows Triple Candlestick Pattern?
    Detect three white soldiers and three black crows triple candlestick pattern.
  • Compare bodies of Three White Soldiers and Three Black Crows candles?
    You also have the possibility of comparing bodies of the candles in a way that every consecutive candle must have a bigger body than the previous candle.
  • Check if each candle (TWS&TBC) opens in the middle price range of the previous day?
    You can check if each candle of three white soldiers and three black crows opens in the middle price range of the previous day.
  • Use Three Inside Up/Down Triple Candlestick Pattern?
    Detect three inside up and three inside down triple candlestick pattern.
  • Check candles' bodies and closing prices for Three Inside Up/Down?
    There are two different definitions for three inside up/down candlestick patterns. This option allows you to select one of those definitions. That is;
    If unchecked, the second candle should make it up all the way to the midpoint of the first candle. Also, the third candle needs to close above the first candle’s high.
    If checked, the second candle opens and closes within the real body of the first candle. Also, the third candle needs to close above the first candle's high.
  • Use Three Line Strike Candlestick Pattern?
    Detect three line strike triple candlestick pattern.
  • Compare High/Lows instead of Open/Close for the Three Line Strike Pattern?
    If checked, it will compare high/lows instead of open/close prices for the three line strike pattern.
  • Use Abandoned Baby Triple Candlestick Pattern?
    Detect abandoned baby triple candlestick pattern. If you choose to tolerate opening and closing prices, high and low prices will also be tolerated for abandoned baby.
  • Use NR4 Candlestick Pattern?
    Detect NR4 candlestick pattern.
  • Use NR7 Candlestick Pattern?
    Detect NR7 candlestick pattern.
  • Confirm Narrow Range Candlestick Patterns with next closing price?
    You can confirm NR4 and NR7 candlestick patterns with the next closing price. That way they will be identified as bullish or bearish patterns.


NOTES FROM THE AUTHOR
  • Please do not hesitate to contact me if you have any questions.
  • If you are not familiar with a specific candlestick pattern, try to google it. If you still need help, you can always contact me.
  • If you find a bug, or you think the indicator does not work as intended, please contact me with a screenshot of the chart. Also, please mention how you set up the user inputs.
  • If you have any ideas to further improve this indicator, please feel free to share it with me :)


LIKE, if you like it. SHARE if you think it would be useful for others too. FOLLOW for future updates and new indicators.
Candlestick Analysiscandlestickpatternpattern-trading

Protected script

This script is published closed-source and you may privately use it freely.

Want to use this script on a chart?

Disclaimer