Analyzing Candlestick Patterns
"Through Inquiring of the Old We Learn the New"
Introduction
Plotting of candlestick charts and analysis of candlestick patterns is an amazing line of technical analysis. The advantage of candlesticks is that they represent data in a way that it is possible to see the momentum within the data.
Candlesticks give a vivid mental picture of trading. After reading and a little practice, candlesticks will be part of your analytical arsenal. Japanese candlestick charts can help you penetrate "inside" of financial markets, which is very difficult to do with other graphical methods. They are equally suitable for all markets.
1. Types of Candlesticks
One of the first analysts who started to predict the movement of prices in the future, based on past prices, was the legendary Japanese Munehisa Homma. Trading principles applied by Homma in trading on the rice market, initiated the technique of Japanese candlesticks, which is now widely used in Japan and abroad.
Figure 1. Structure of a candlestick
Consider the structure of a candlestick (Fig. 1). The rectangle representing the difference between the open and close prices, is called the body of the candlestick. The height of the body represents the range between the open and close prices of the trading period. When the close price is higher than the open price, the candlestick body is white (Fig. 1 a). If the body is black (Fig. 1 b), this means the close price was below the open price.
Candlesticks can have shadows - the upper and lower, the length of shadows depends on the distance between the open/close prices and the minimum/maximum prices.
Candlestick are plotted on the chart one by one, forming various patterns. According to the theory, some patterns can indicate with a certain probability that the trend is changing, or confirm the trend, or show that the market is indecisive.
Long bodies of candlesticks, as a rule, tell about pressure from buyers or sellers (depending on the color of the candlestick). Short bodies mean that the struggle between the bulls and bears was weak.
Candlesticks | Description |
---|---|
"Long Candlesticks". Link to long candlesticks is widespread in the literature on Japanese candlesticks. The term "long" refers to a candlestick body length, the difference between the open price and the close price. It is better to consider the most recent price movements to determine what is long, and what is not. Five or ten previous days - that's quite an adequate period to arrive at a correct conclusion. | |
"Short Candlesticks". The determination of short candlesticks can be based on the same methodology as in the case of long candlesticks, with similar results. In addition, there are a lot of candlesticks, which do not fall into any of these two categories. | |
"Marubozu" . In Japanese "Marubozu" means almost bold. In any case, the meaning of the term reflects the fact that the body of the candlestick either does not have up and/or down shadows at all, or they are very small. Black marubozu - a long black body without a shadow on one of the sides. It often becomes a part of the bearish continuation pattern or bull reversal pattern, especially it appears in a downtrend. A long black candlestick indicates a major victory of bears, so it often appears the first day of many reversal patterns of the bullish character. White marubozu - a long white body without a shadow on one of the sides. This is a very strong candle. In contrast to the black marubozu it often turns out to be part of the bullish pattern of continuation or a bearish reversal pattern. | |
"Doji". If the body of the candlestick is so small that the open and close prices are the same, it is called Doji. The requirement that the open and close prices should be exactly equal, imposes ti strict restrictions on the data, and Doji would appear very rarely. If the price difference between the open and close prices does not exceed a few ticks (minimum price change), this is more than enough. | |
"Spinning Tops" are short candlesticks with an upper and/or lower shadow longer than the body. Sometimes they are referred to as "white" and "black" Doji. Koma indicates indecision of bulls and bears. The color of the Koma body, as well as the length of its shadow, is not important. The small body relative to the shadows is what makes the spinning top. | |
"Hanging man" and "Hammer". These are candlesticks with long lower shadows and short bodies. The bodies are at the top of the range of prices. The surprising property of these candlesticks is that they can be bullish and bearish, depending on the phase of the trends, in which they appear. The appearance of these candles in a downward trend is a signal that its dominance in the market is coming to an end, in this case the candlestick is called "the hammer". If the candlestick appears during an uptrend, it indicates its possible end, and the candlestick has an ominous name - "hanging man". | |
"A start" appears each time when the small body appears whenever a small body opens up or down from the previous long body, body color is unimportant. Ideally, the gap must catch also shadows, but it is not entirely necessary. The star indicates some uncertainty prevailing in the market. Stars are included in many candlestick patterns, mostly reversal. |
Table 1. Types of Candlesticks
Separate candlesticks are extremely important for the analysis of combinations of candlesticks. When an analyst uses them separately, and then in combination with other candlesticks, the psychological state of the market is revealed.
2. Identification of the basic types of candlesticks
2.1. Necessary structures
Candlestick patterns can be a separate candlestick or consist of a few of them. For the candlestick patterns, there are certain rules of recognition.
Example:Evening star (bearish pattern). The trend upwards. The first and third candlesticks are "long". Shadows of the stars are short, the color does not matter. The classical pattern: separation of the star from the Close of the first candlestick, for forex and within the day: Close of the first candlestick and Open of the star are equal. The third candlestick is closed inside the body of the first one.
So first let's learn to recognize the types of candlesticks. For this purpose, we write a function RecognizeCandle, which will recognize the type of candlesticks and return the necessary information.
//+------------------------------------------------------------------+ //| Function of candlestick type recognition | //+------------------------------------------------------------------+ bool RecognizeCandle(string symbol,ENUM_TIMEFRAMES period, datetime time,int aver_period,CANDLE_STRUCTURE &res)where:
- symbol - the name of the symbol
- period – chart period,
- time – open time of the candlestick,
- aver_period - period of averaging
- res - a structure, in which the result is returned.
Let's define what results we need, based on the rules of recognition of candlestick patterns:
- open, close, high and low;
- open time of the candlestick;
- trend direction;
- bullish or bearish candlestick;
- size of the candlestick body – an absolute value;
- type of candlestick (from Table 1).
Let's create a structure:
//+------------------------------------------------------------------+ //| Structure CANDLE_STRUCTURE | //+------------------------------------------------------------------+ struct CANDLE_STRUCTURE { double open,high,low,close; // OHLC datetime time; //Time TYPE_TREND trend; //Trend bool bull; //Bull candlestick double bodysize; //Body size TYPE_CANDLESTICK type; //Type of candlestick };
where trend and type are variables of enumeration type:
//+------------------------------------------------------------------+ //| ENUM TYPE CANDLESTICK | //+------------------------------------------------------------------+ enum TYPE_CANDLESTICK { CAND_NONE, //Unrecognized CAND_MARIBOZU, //Marubozu CAND_MARIBOZU_LONG, //Marubozu long CAND_DOJI, //Doji CAND_SPIN_TOP, //Spinning Tops CAND_HAMMER, //Hammer CAND_INVERT_HAMMER, //Reverse hammer CAND_LONG, //Long CAND_SHORT, //Short CAND_STAR //Star }; //+------------------------------------------------------------------+ //| TYPE_TREND | //+------------------------------------------------------------------+ enum TYPE_TREND { UPPER, //Upward DOWN, //Downward LATERAL //Lateral };
Let us consider the RecognizeCandle function.
2.2. Recognition of the candlestick type
//+------------------------------------------------------------------+ //| Function of recognition of candlestick type | //+------------------------------------------------------------------+ bool RecognizeCandle(string symbol,ENUM_TIMEFRAMES period, datetime time,int aver_period,CANDLE_STRUCTURE &res) { MqlRates rt[]; //--- Get data of previous candlesticks if(CopyRates(symbol,period,time,aver_period+1,rt)<aver_period) { return(false); }
First, using the CopyRates function obtain data from previous aver_period +1 candlesticks. Note the order, in which data is stored in the array we obtain.
If data were received without errors, start filling out our return structure CANDLE_STRUCTURE with data.
res.open=rt[aver_period].open; res.high=rt[aver_period].high; res.low=rt[aver_period].low; res.close=rt[aver_period].close; res.time=rt[aver_period].time;
Defining trend. What is a trend? If this question had a fairly complete answer, the secrets of the market would have been disclosed. In this article we will use the method for determining the trend using a moving average.
MA=(C1+C2+…+Cn)/N,
where C – close prices, N – number of bars.
L. Morris in his book "Candlestick Charticng Explained. Timeless techniques for Trading Stocks and Futures" uses to a moving average with a period of ten to identify a short-term trend; if the close price is above average - the trend is up, if lower - it is downward.
That's how it looks like:
//--- Define the trend direction double aver=0; for(int i=0;i<aver_period;i++) { aver+=rt[i].close; } aver=aver/aver_period; if(aver<res.close) res.trend=UPPER; if(aver>res.close) res.trend=DOWN; if(aver==res.close) res.trend=LATERAL;
Next we define if our candle is bullish or bearish, we calculate the absolute value of the candlestick body, the size of shadows, the average body size of the candlestick during aver_period and other necessary intermediate data.
//--- Define of it bullish or bearish res.bull=res.open<res.close; //--- Get the absolute value of the candlestick body size res.bodysize=MathAbs(res.open-res.close); //--- Get the size of shadows double shade_low=res.close-res.low; double shade_high=res.high-res.open; if(res.bull) { shade_low=res.open-res.low; shade_high=res.high-res.close; } double HL=res.high-res.low; //--- Calculate the average body size of previous candlesticks double sum=0; for(int i=1; i<=aver_period; i++) sum=sum+MathAbs(rt[i].open-rt[i].close); sum=sum/aver_period;
Now let's deal with the identification of the types of candlesticks.
2.3. Rules of identification of candlestick types
"Long" candlesticks. To define "long" candlesticks, check the value of the current candlestick relative to the average value of aver_period previous candles.
(Body) > (average body of the last five days) *1.3
//--- long if(res.bodysize>sum*1.3) res.type=CAND_LONG;
"Short" candlesticks. To define "short" candlesticks, use the same principle as for the "long" ones, but with a changed condition.
(Body) > (average body of the last X days) *0.5
//--- short if(res.bodysize<sum*0.5) res.type=CAND_SHORT;
Doji. Doji occurs when open and close prices are equal. This is a very strict rule. In the case of most types of data, we can tolerate some deviations in finding patterns. The formula allows finding the percentage difference between the two prices within acceptable limits.
(Dodji body) < (range from the highest to the lowest prices) * 0.03
//--- doji if(res.bodysize<HL*0.03) res.type=CAND_DOJI;
"Marubozu" . This is a candlestick with no high or low, or they are very small
(lower shadow) < (body) * 0.03 or (upper shadow) < (body) * 0.03
//--- maribozu if((shade_low<res.bodysize*0.01 || shade_high<res.bodysize*0.01) && res.bodysize>0) { if(res.type==CAND_LONG) res.type=CAND_MARIBOZU_LONG; else res.type=CAND_MARIBOZU; }
When writing an indicator for this article, it was necessary to separate the "long" "Maribozu", for which I had to add the condition for checking "long" candlesticks.
"Hammer" and "Hanging Man". The body is located in the upper part of the daily range and the lower shadow is much longer than the body. It is also necessary to consider the length of the upper shadow, if there is any. The ratio between the body and the lower shadow is defined as the ratio of the body length to the length of the lower shadow:
(lower shadow)>(body)*2 and (upper shadow)< (body)*0.1
//--- hammer if(shade_low>res.bodysize*2 && shade_high<res.bodysize*0.1) res.type=CAND_HAMMER;
"Shooting Star" and "Inverted Hammer" are similar to the "Hammer", but with the opposite condition:
(lower shadow)<(body)*0.1 and (upper shadow)> (body)*2
//--- invert hammer if(shade_low<res.bodysize*0.1 && shade_high>res.bodysize*2) res.type=CAND_INVERT_HAMMER;
"Spinning Tops". These are "short" candlesticks" with shadows longer than the body:
(lower shadow) > (body) and (upper shadow) > (body)
//--- spinning top if(res.type==CAND_SHORT && shade_low>res.bodysize && shade_high>res.bodysize) res.type=CAND_SPIN_TOP;
The source text of the function and structure descriptions are in the attached file CandlestickType.mqh.
A;so to the article, the Candlestick Type Color.mq5 indicator is attached, which paints candlesticks on the chart depending on their type.
Figure 2. Example of Candlestick Type Color.mq5
So we have created a function that returns all the necessary data.
Now we cane proceed creating an indicator that will recognize candlestick patterns.
3. Candlestick Patterns and Algorithms for Their Identification
A candlestick pattern can be either a single candlestick, or consist of several candlesticks, seldom more than five or six. In Japanese literature, they sometimes refer to the patterns consisting of a larger number of candlesticks. The order in which we will consider the patterns, does not reflect their importance or predictive capabilities.
Candlestick patterns are divided into two types - reversal patterns and continuation patterns.
We will consider simple patterns (one candlestick) first, and then complex (several candlesticks). The figure containing the pattern will start with two small vertical lines. These lines simply indicate the direction of the previous trend of the market, and should not be used as a direct indication of the relations between patterns.
The patterns will be presented in a table, in the first line - bull pattern, in the second - the opposite bearish pattern, if there is such.
3.1. REVERSAL PATTERNS OF CANDLESTICKS
3.1.1. Patterns consisting of a single candlestick
Obtain data for a single candlestick:
//--- calculation of candlestick patterns for(int i=limit;i<rates_total-1;i++) { CANDLE_STRUCTURE cand1; if(!RecognizeCandle(_Symbol,_Period,time[i],InpPeriodSMA,cand1)) continue; /* Checking patterns with one candlestick */
and recognize patterns.
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Inverted hammer (bullish) |
Buy |
Downward trend. | ||
Hanging Man (bearish) |
Sell |
Uptrend. The lower shadow is not less than 2 and no more than 3 times larger than the body. There is no upper shadow, or it is very short (no more than 10% of the candlestick range). The color of the body in the long game is not important, with the short - the black hanging man is much stronger than the white one. Confirmation is suggested. |
//------ // Inverted Hammer the bull model if(cand1.trend==DOWN && // check the trend direction cand1.type==CAND_INVERT_HAMMER) // check the "inverted hammer" { comment=_language?"Inverted hammer"; DrawSignal(prefix+"Inverted Hammer the bull model"+string(objcount++),cand1,InpColorBull,comment); } // Handing Man the bear model if(cand1.trend==UPPER && // check the trend direction cand1.type==CAND_HAMMER) // check "hammer" { comment=_language?"Hanging Man"; DrawSignal(prefix+"Hanging Man the bear model"+string(objcount++),cand1,InpColorBear,comment); }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Hammer (bullish) |
Buy |
Downward trend. The lower shadow is not less than 2 and no more than 3 times larger than the body. There is no upper shadow, or it is very short (no more than 10% of the candlestick range). The color of the body in the long game is not important, with the short - white hammer is much stronger than the black one. Confirmation is suggested. | ||
Shooting Star (bearish) |
Sell |
Uptrend. The upper shadow is not less than 3 times is larger than the body. There is no lower shadow, or it is very short (no more than 10% of the candlestick range). The price gap between the star and the previous candlestick. Forex: the Close price of the previous candlestick and Open of the Star are equal. The body color does not matter. Confirmation is suggested. |
//------ // Hammer the bull model if(cand1.trend==DOWN && //check the trend direction cand1.type==CAND_HAMMER) // check the hammer { comment=_language?"Hammer"; DrawSignal(prefix+"Hammer the bull model"+string(objcount++),cand1,InpColorBull,comment); } //------ // Shooting Star the bear model if(cand1.trend==UPPER && cand2.trend==UPPER && //check the trend direction cand2.type==CAND_INVERT_HAMMER) // check the inverted hammer { comment=_language?"Shooting Star"; if(_forex)// if forex { if(cand1.close<=cand2.open) // close 1 less equal open 1 { DrawSignal(prefix+"Shooting Star the bear model"+string(objcount++),cand2,InpColorBear,comment); } } else { if(cand1.close<cand2.open && cand1.close<cand2.close) // 2 candlestick detached from 1 { DrawSignal(prefix+"Shooting Star the bear model"+string(objcount++),cand2,InpColorBear,comment); } } }
I would like to draw your attention to the fact that in the case of "Shooting Star" we actually need two candlesticks, because under the terms of recognizing the body of the previous day is taken into account.
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Belt Hold (bullish) |
Buy |
The pattern is not implemented |
Downward trend. Opening of a candlestick with a large gap in the direction of the trend. White candlestick — «marubozu» «long». The body of the white candlestick is much larger than the body of the previous candlestick. Confirmation is suggested. | |
Belt Hold (bearish) |
Sell |
The pattern is not implemented |
Uptrend. Opening of a candlestick with a large gap in the direction of the trend. Black candlestick — «marubozu» «long». The body of the black candlestick is much larger than the body of the previous candlestick. Confirmation is suggested. |
//------ // Belt Hold the bull model if(cand2.trend==DOWN && cand2.bull && !cand1.bull &&// check the trend direction and direction of the candlestick cand2.type==CAND_MARIBOZU_LONG && // check the "long" marubozu cand1.bodysize<cand2.bodysize && cand2.close<cand1.close) // the body of the first candlestick is smaller than the body of the second one, close of the second one is below the close of the first { comment=_language?"Belt Hold"; if(!_forex)// if not forex { DrawSignal(prefix+"Belt Hold the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } // Belt Hold the bear model if(cand2.trend==UPPER && !cand2.bull && cand1.bull && // check the trend direction and direction of the candlestick cand2.type==CAND_MARIBOZU_LONG && // check the "long" marubozu cand1.bodysize<cand2.bodysize && cand2.close>cand1.close) // the body of the first candlestick is smaller than the body of the second one, close of the second one is above the close of the first { comment=_language?"Belt Hold"; if(!_forex)// if not forex { DrawSignal(prefix+"Belt Hold the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } }
Like in the case with the "Shooting Star", two candlesticks are used, because the body of the previous day is taken into account for pattern recognition.
3.1.2. Patterns consisting of two candlesticks
Add another candle:
/* Checking patterns with two candlesticks */ CANDLE_STRUCTURE cand2; cand2=cand1; if(!RecognizeCandle(_Symbol,_Period,time[i-1],InpPeriodSMA,cand1)) continue;
and recognize patterns:
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Engulfing (bullish) |
Buy |
Downward trend. | ||
Engulfing (bearish) |
Sell |
Uptrend. The body of the second candlestick completely covers the body of the first one. Forex: Close of the white candlestick and Open of the black one match. Shadows do not matter. Confirmation is suggested. |
//------ // Engulfing the bull model if(cand1.trend==DOWN && !cand1.bull && cand2.trend==DOWN && cand2.bull && // check the trend direction and direction of the candlestick cand1.bodysize<cand2.bodysize) // the body of the second candlestick is larger than that of the first { comment=_language?"Engulfing"; if(_forex)// if forex { if(cand1.close>=cand2.open && cand1.open<cand2.close) // the body of the first candlestick is inside the body of the second { DrawSignal(prefix+"Engulfing the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } else { if(cand1.close>cand2.open && cand1.open<cand2.close) // the body of the first candlestick is inside the body of the second { DrawSignal(prefix+"Engulfing the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } } // Engulfing the bear model if(cand1.trend==UPPER && cand1.bull && cand2.trend==UPPER && !cand2.bull && // check the trend direction and direction of the candlestick cand1.bodysize<cand2.bodysize) // the body of the second candlestick is larger than that of the first { comment=_language?"Engulfing"; if(_forex)// if forex { if(cand1.close<=cand2.open && cand1.open>cand2.close) //the body of the first candlestick is inside the body of the second { DrawSignal(prefix+"Engulfing the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } else { if(cand1.close<cand2.open && cand1.open>cand2.close) // close 1 less equal to open 2 or open 1 larger equal to close 2 { DrawSignal(prefix+"Engulfing the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Harami Cross (Bull) |
Buy |
Downward trend. | ||
Harami Cross (bearish) |
Sell |
Uptrend. The first candlestick of the pattern is long white. Doji is within the range of the first candlestick, including the shades. Forex: doji is on the level of Close of the first candlestick. If Doji shadows are short, the pattern should be considered a Doji Star for forex. Confirmation is suggested. |
//------ // Harami Cross the bull model if(cand1.trend==DOWN && !cand1.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && cand2.type==CAND_DOJI) // checking the "long" first candlestick and doji { comment=_language?""Harami Cross"; if(_forex)// if forex { if(cand1.close<=cand2.open && cand1.close<=cand2.close && cand1.open>cand2.close) // doji inside the body of the first candlestick { DrawSignal(prefix+"Harami Cross the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } else { if(cand1.close<cand2.open && cand1.close<cand2.close && cand1.open>cand2.close) // doji inside the body of the first candlestick { DrawSignal(prefix+"Harami Cross the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } } // Harami Cross the bear model if(cand1.trend==UPPER && cand1.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && cand2.type==CAND_DOJI) // checking the "long" candlestick and doji { comment=_language?"Harami Cross"; if(_forex)// if forex { if(cand1.close>=cand2.open && cand1.close>=cand2.close && cand1.close>=cand2.close) // doji inside the body of the first candlestick { DrawSignal(prefix+"Harami Cross the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } else { if(cand1.close>cand2.open && cand1.close>cand2.close && cand1.open<cand2.close) // doji inside the body of the first candlestick { DrawSignal(prefix+"Harami Cross the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Harami (bullish) |
Buy |
Downward trend. | ||
Harami (bearish) |
Sell |
Uptrend. The body of the first "long" candlestick" completely engulfs the body of the second one. Shadows do not matter. Forex: Close of the white candlestick and Open of black match. Confirmation is suggested. |
//------ // Harami the bull model if(cand1.trend==DOWN && !cand1.bull && cand2.bull &&// check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && // checking the "long"first candlestick cand2.type!=CAND_DOJI && cand1.bodysize>cand2.bodysize) // the second candlestick is not doji and the body of the first is larger than the body of the second { comment=_language?"Harami"; if(_forex)// if forex { if(cand1.close<=cand2.open && cand1.close<=cand2.close && cand1.open>cand2.close) // body of the second candlestick is inside the body of the first { DrawSignal(prefix+"Harami the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } else { if(cand1.close<cand2.open && cand1.close<cand2.close && cand1.open>cand2.close) // body of the second candlestick is inside the body of the first { DrawSignal(prefix+"Harami the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } } // Harami the bear model if(cand1.trend==UPPER && cand1.bull && !cand2.bull &&// check the trend direction and direction of candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && // checking the "long" first candlestick cand2.type!=CAND_DOJI && cand1.bodysize>cand2.bodysize) // the second candlestick is not doji and body of the first candlestick is larger than that of the second { comment=_language?"Harami"; if(_forex)// if forex { if(cand1.close>=cand2.open && cand1.close>=cand2.close && cand1.close>=cand2.close) // doji is inside the body of the first candlestick { DrawSignal(prefix+"Harami the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } else { if(cand1.close>cand2.open && cand1.close>cand2.close && cand1.open<cand2.close) //doji is inside the body of the first candlestick { DrawSignal(prefix+"Harami the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Doji Star (bullish) |
Buy |
Downward trend. | ||
Doji Star (bearish) |
Sell |
Uptrend. The first candlestick of the pattern is long white. The second session - doji with a break in the trend direction. Forex: no break. Shadows of doji are short. Confirmation is suggested. |
//------ // Doji Star the bull model if(cand1.trend==DOWN && !cand1.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && cand2.type==CAND_DOJI) // checking 1 "long" candlestick and 2 doji { comment=_language?"Doji Star"; if(_forex)// if forex { if(cand1.close>=cand2.open) // open of doji is below or equal to close of the first candlestick { DrawSignal(prefix+"Doji Star the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } else { if(cand1.close>cand2.open && cand1.close>cand2.close) // the body of doji is alienated from the body of the first candlestick { DrawSignal(prefix+"Doji Star the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } } // Doji Star the bear model if(cand1.trend==UPPER && cand1.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && cand2.type==CAND_DOJI) // checking 1 "long" candlestick and 2 doji { comment=_language?"Doji Star"; if(_forex)// if forex { if(cand1.close<=cand2.open) // // open of doji is above or equal to close of the first candlestick { DrawSignal(prefix+"Doji Star the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } else { if(cand1.close<cand2.open && cand1.close<cand2.close) // // the body of doji is alienated from the body of the first candlestick { DrawSignal(prefix+"Doji Star the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Piercing Pattern (bullish) |
Buy |
Downward trend. Both candlesticks are long. Open of the white candlestick is below Low of the black. Forex: Close of the black candlestick and Open of white are equal. The white candlestick is closed inside the black one and covers more than 50% of the body. (For stock markets: unlike Dark-cloud cover, this requirement has no exceptions.) Confirmation is not required for the classical model, is required for Forex. | ||
Dark Cloud Cover (Bear) |
Sell |
Uptrend. Both candlesticks are long. Open of the black candlestick is above High of the white candlestick. Forex: Close of the white candlestick and Open of black are equal. The black candle closes inside white and covers more than 50% of the body. Confirmation is not required for the classical model, is required for Forex. |
//------ // Piercing line the bull model if(cand1.trend==DOWN && !cand1.bull && cand2.trend==DOWN && cand2.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand2.close>(cand1.close+cand1.open)/2)// close of the second is above the middle of the first { comment=_language?"Piercing Line"; if(_forex)// if forex { if(cand1.close>=cand2.open && cand2.close<=cand1.open) { DrawSignal(prefix+"Gleam in clouds"+string(objcount++),cand1,cand2,InpColorBull,comment); } } else { if(cand2.open<cand1.low && cand2.close<=cand1.open) // open of the second candlestick is below LOW of the first, { DrawSignal(prefix+"Piercing Line"+string(objcount++),cand1,cand2,InpColorBull,comment); } } } // Dark Cloud Cover the bear model if(cand1.trend==UPPER && cand1.bull && cand2.trend==UPPER && !cand2.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand2.close<(cand1.close+cand1.open)/2)// close 2 is below the middle of the body of 1 { comment=_language?"Dark Cloud Cover"; if(_forex)// if forex { if(cand1.close<=cand2.open && cand2.close>=cand1.open) { DrawSignal(prefix+"Dark Cloud Cover"+string(objcount++),cand1,cand2,InpColorBear,comment); } } else { if(cand1.high<cand2.open && cand2.close>=cand1.open) { DrawSignal(prefix+"Dark Cloud Cover"+string(objcount++),cand1,cand2,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Meeting Lines (bullish) |
Buy |
The pattern is not implemented |
Downward trend. The first candlestick of the pattern is long black. Open of the white candlestick is with a large gap and is below the Low of the black candlestick. Close prices of both candlesticks are the same. The body of the white candlestick is larger than the body of the black candlestick. Confirmation is suggested. | |
Meeting Lines (bearish) |
Sell |
The pattern is not implemented |
Uptrend. The first candlestick of the pattern is long white. Open of the black candlestick is with a large gap and is above the High of the white candlestick. Close prices of both candlesticks are the same. The body of the black candlestick is larger than the body of the white candlestick. Confirmation is suggested. |
// Meeting Lines the bull model if(cand1.trend==DOWN && !cand1.bull && cand2.trend==DOWN && cand2.bull && // check the trend direction and the candlestick direction (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand1.close==cand2.close && cand1.bodysize<cand2.bodysize && cand1.low>cand2.open) // close prices are equal, size of the first one is less than of the second one, open of the second is below Low of the first { comment=_language?"Meeting Lines"; if(!_forex)// if not forex { DrawSignal(prefix+"Meeting Lines the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } // Meeting Lines the bear model if(cand1.trend==UPPER && cand1.bull && cand2.trend==UPPER && !cand2.bull && // check the trend direction and the candlestick direction (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand1.close==cand2.close && cand1.bodysize<cand2.bodysize && cand1.high<cand2.open) // // close prices are equal, size of first is less than of second, open of the second is above High of the first { comment=_language?"Meeting Lines"; if(!_forex)// if not forex { DrawSignal(prefix+"Meeting Lines the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Matching Low (bullish) |
Buy |
The pattern is not implemented |
Downward trend. The first candlestick of the pattern must not necessarily be long. Open of the second candlestick is inside the body of the first one. Close prices of both prices are the same. there are no lower shadows or they are very short. Confirmation is suggested. |
//------ // Matching Low the bull model if(cand1.trend==DOWN && !cand1.bull && cand2.trend==DOWN && !cand2.bull && // check the trend direction and the candlestick direction cand1.close==cand2.close && cand1.bodysize>cand2.bodysize) // close prices are equal, size of the first one is larger than of the second { comment=_language?"Matching Low"; if(!_forex)// if not forex { DrawSignal(prefix+"Matching Low the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Homing Pigeon<br1(bullish) Bullish Homing Pigeon |
Buy |
The pattern is not implemented |
Downward trend. The first candlestick of the pattern must not necessarily be long. Open of the second candlestick is inside the body of the first one. Close prices of both prices are the same. there are no lower shadows or they are very short. Confirmation is suggested. |
//------ // Homing Pigeon the bull model if(cand1.trend==DOWN && !cand1.bull && cand2.trend==DOWN && !cand2.bull && // check the trend direction and the candlestick direction (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand1.close<cand2.close && cand1.open>cand2.open) // body of the second is inside that of the first candlestick { comment=_language?"Homing Pigeon"; if(!_forex)// if not forex { DrawSignal(prefix+"Homing Pigeon the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } }
3.1.3. Patterns consisting of three candlesticks
/* Checking patterns with three candlesticks */ CANDLE_STRUCTURE cand3; cand3=cand2; cand2=cand1; if(!RecognizeCandle(_Symbol,_Period,time[i-2],InpPeriodSMA,cand1)) continue;
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Abandoned Baby (bullish) |
Buy |
The pattern is not implemented |
This is a rare but important reversal pattern. | |
Abandoned Baby (bearish) |
Sell |
The pattern is not implemented |
This is a rare but important reversal pattern. |
//------ // The Abandoned Baby, the bullish model if(cand1.trend==DOWN && !cand1.bull && cand3.trend==DOWN && cand3.bull && // check direction of trend and direction of candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // check of "long" candlestick cand2.type==CAND_DOJI && // check if the second candlestick is Doji cand3.close<cand1.open && cand3.close>cand1.close) // the third one is closed inside of body of the first one { comment=_language?"Abandoned Baby (Bull)":"Abandoned Baby"; if(!_forex)// if it's not forex { if(cand1.low>cand2.high && cand3.low>cand2.high) // gap between candlesticks { DrawSignal(prefix+"Abandoned Baby the bull model"+string(objcount++),cand1,cand1,cand3,InpColorBull,comment); } } } // The Abandoned Baby, the bearish model if(cand1.trend==UPPER && cand1.bull && cand3.trend==UPPER && !cand3.bull && // check direction of trend and direction of candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // check of "long" candlestick cand2.type==CAND_DOJI && // check if the second candlestick is Doji cand3.close>cand1.open && cand3.close<cand1.close) // // the third one is closed inside of body of the second one { comment=_language?"Abandoned Baby (Bear)":"Abandoned Baby"; if(!_forex)// if it's not forex { if(cand1.high<cand2.low && cand3.high<cand2.low) // gap between candlesticks { DrawSignal(prefix+"Abandoned Baby the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Morning Star (bullish) |
Buy |
Downward trend. The first and the third sessions are "long" candlesticks. Shadows of the stars are short, the color does not matter. Separation of the star from the Close of the first candlestick. Forex: Close of the first candlestick and Open of the star are equal. The third candlestick is closed inside the body of the first one. | ||
Evening Star (bearish) |
Sell |
Uptrend. The first and the third sessions are "long" candlesticks. Shadows of the stars are short, the color does not matter. Separation of the star from the Close of the first candlestick. Forex: Close of the first candlestick and Open of the star are equal. The third candlestick is closed inside the body of the first one. |
// Morning star the bull model if(cand1.trend==DOWN && !cand1.bull && cand3.trend==DOWN && cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand2.type==CAND_SHORT && // checking "short" cand3.close>cand1.close && cand3.close<cand1.open) // the third candlestick is closed inside the body of the first one { comment=_language?"Morning star"; if(_forex)// if forex { if(cand2.open<=cand1.close) // open of the second candlestick is below or equal to close of the first one { DrawSignal(prefix+"Morning star the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } else // another market { if(cand2.open<cand1.close && cand2.close<cand1.close) // separation of the second candlestick from the first one { DrawSignal(prefix+"Morning star the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } } // Evening star the bear model if(cand1.trend==UPPER && cand1.bull && cand3.trend==UPPER && !cand3.bull && //check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand2.type==CAND_SHORT && // checking "short" cand3.close<cand1.close && cand3.close>cand1.open) // the third candlestick is closed inside the body of the first one { comment=_language?"Evening star"; if(_forex)// if forex { if(cand2.open>=cand1.close) // open of the second is above or equal to close of the first one { DrawSignal(prefix+"Evening star the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } else // another market { if(cand2.open>cand1.close && cand2.close>cand1.close) // separation of the second candlestick from the first one { DrawSignal(prefix+"Evening star the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Morning Doji Star (bullish) |
Buy |
Downward trend. The first candlestick of the pattern is long black. The second session - doji with a break in the trend direction. Forex: no break. Shadows of doji are short. The third candlestick is closed inside the body of the first one. | ||
Evening Doji Star (bearish) |
Sell |
Uptrend. The first candlestick of the pattern is long white. The second session - doji with a break in the trend direction. Forex: no break. Shadows of doji are short. Confirmation is suggested. |
//------ // Morning Doji Star the bull model if(cand1.trend==DOWN && !cand1.bull && cand3.trend==DOWN && cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand2.type==CAND_DOJI && // checking "doji" cand3.close>cand1.close && cand3.close<cand1.open) // third cand. is closed inside body of first { comment=_language?"Morning Doji Star"; if(_forex)// if forex { if(cand2.open<=cand1.close) // open of doji is below or equal to close of the first { DrawSignal(prefix+"Morning Doji Star the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } else // another market { if(cand2.open<cand1.close) // separation of doji from the first { DrawSignal(prefix+"Morning Doji Star the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } } // Evening Doji Star the bear model if(cand1.trend==UPPER && cand1.bull && cand3.trend==UPPER && !cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand2.type==CAND_DOJI && // checking "doji" cand3.close<cand1.close && cand3.close>cand1.open) // third cand. is closed inside body of first { comment=_language?"Evening Doji Star"; if(_forex)// if forex { if(cand2.open>=cand1.close) // open of doji is above or equal to close of the first { DrawSignal(prefix+"Evening Doji Star the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } else // another market { if(cand2.open>cand1.close) // separation of doji from the first // check close 2 and open 3 { DrawSignal(prefix+"Evening Doji Star the bear model"+string(objcount++),cand1,cand3,cand3,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Bearish Upside Gap Two Crows |
Sell |
The pattern is not implemented |
Uptrend. The first candlestick is "long" white. A gap between white and black candlesticks. The third candlestick opens higher than the second and engulfs it. Confirmation is suggested. The meaning of the pattern: if prices could not go up during the 4th session, we should expect prices to fall. | |
Two Crows (bearish) |
Sell |
The pattern is not implemented |
Uptrend. The first candlestick of the pattern is long white. The gap between white and the first black candlestick. The third candlestick is black and necessarily "long"; opens inside or above the second and closes within or below the white candlestick, covering the gap. Confirmation is suggested. If the second crow (the third candle) engulfs a white candle, the confirmation is not required. |
//------ // Upside Gap Two Crows the bear model if(cand1.trend==UPPER && cand1.bull && cand2.trend==UPPER && !cand2.bull && cand3.trend==UPPER && !cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand1.close<cand2.close && cand1.close<cand3.close && // separation of the second and third from the first one cand2.open<cand3.open && cand2.close>cand3.close) // the third candlestick engulfs second { comment=_language?"Upside Gap Two Crows"; if(!_forex)// if not forex { DrawSignal(prefix+"Upside Gap Two Crows the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } //------ // Two Crows the bear model if(cand1.trend==UPPER && cand1.bull && cand2.trend==UPPER && !cand2.bull && cand3.trend==UPPER && !cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG|| cand1.type==CAND_MARIBOZU_LONG) &&(cand3.type==CAND_LONG|| cand3.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand1.close<cand2.close && // separation of the second from the first one cand3.open>cand2.close && // third one opens higher than close of the second cand3.close<cand1.close) // third one closes than close of the first { comment=_language?"Two Crows"; if(!_forex)// if not forex { DrawSignal(prefix+"Two Crows the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Three Star in the South (bullish) |
Buy |
Downward trend. The first candlestick is a long black day with a long lower shadow. The second candlestick is shorter than the first, its Low is above the Low of the first candlestick. The third candlestick is a small black marubozu or a star, an internal day in relation to the second session. Confirmation is suggested. | ||
Deliberation (bearish) |
Sell |
Uptrend. Three white candlesticks with higher close prices. The first two candlesticks are long days. Open price of each candlestick is inside the body of the preceding one. Forex: open/close prices of white candlesticks are the same. The third candlestick opens at about the close level of the second candlestick. the third candlestick is a star or a spinning top. Confirmation is suggested. |
//------ // Three Star in the South the bull model if(cand1.trend==DOWN && !cand1.bull && !cand2.bull && !cand3.bull && //check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand3.type==CAND_MARIBOZU || cand3.type==CAND_SHORT) && // checking the "long" candlestick and marubozu cand1.bodysize>cand2.bodysize && cand1.low<cand2.low && cand3.low>cand2.low && cand3.high<cand2.high) { comment=_language?"Three Star in the South"; if(_forex)// if forex { DrawSignal(prefix+"Three Star in the South the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } else // another market { if(cand1.close<cand2.open && cand2.close<cand3.open) // open is inside the previous candlestick { DrawSignal(prefix+"Three Star in the South the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } } // Deliberation the bear model if(cand1.trend==UPPER && cand1.bull && cand2.bull && cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick (cand3.type==CAND_SPIN_TOP || cand3.type==CAND_SHORT)) // the third candlestick is a star or spinning top { comment=_language?"Deliberation"; if(_forex)// if forex { DrawSignal(prefix+"Deliberation the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } else // another market { if(cand1.close>cand2.open && cand2.close<=cand3.open) // open is inside the previous candlestick // check close 2 and open 3 { DrawSignal(prefix+"Deliberation the bear model"+string(objcount++),cand1,cand3,cand3,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Three White Soldiers (bullish) |
Buy |
Downward trend. Three long white candlesticks appear one after another, close prices of each of them is higher than that of the previous. Open price of each soldier is inside the body of the previous candlestick. Forex: Close/Open of solders are the same. Upper shadows of the soldiers are short. Confirmation is not required. | ||
Three Black Crows (bearish) |
Sell |
The pattern is not implemented |
Uptrend. Three long black candlesticks appear one after another, close prices of each of them is lower than that of the previous. Open price of each crow is inside the body of the previous candlestick. Forex: corresponds to pattern Identical three crows. The lower shadows of the crows are short. Confirmation is not required. |
//------ // Three White Soldiers the bull model if(cand1.trend==DOWN && cand1.bull && cand2.bull && cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick and marubozu (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG)) // checking the "long" candlestick and marubozu { comment=_language?"Three White Soldiers"; if(_forex)// if forex { DrawSignal(prefix+"Three White Soldiers the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } else // another market { if(cand1.close>cand2.open && cand2.close>cand3.open) // open inside the previous candlestick { DrawSignal(prefix+"Three White Soldiers the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } } // Three Black Crows the bear model if(cand1.trend==UPPER && !cand1.bull && !cand2.bull && !cand3.bull && //check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick and marubozu (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick and marubozu cand1.close<cand2.open && cand2.close<cand3.open) { comment=_language?"Three Black Crows"; if(!_forex) // non-forex { DrawSignal(prefix+"Three Black Crows the bear model"+string(objcount++),cand1,cand3,cand3,InpColorBear,comment); } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Three Outside Up (bullish) |
Buy |
Downward trend. First the pattern of Engulfing (bull) is formed: the body of the second candlestick completely covers the body of the first one. Forex: Close of a black candlestick and Open of the white one are equal. Shadows do not matter. Then, on the third day there is a higher close. Confirmation is not required: the pattern itself is a confirmation to the bull Engulfing | ||
Three Outside Down (bearish) |
Sell |
Uptrend. First the pattern of Engulfing (bear) is formed: the body of the second candlestick completely covers the body of the first one. Forex: Close of the white candlestick and Open of the first black one match. Shadows do not matter. Then, on the third day there is a lower close. Confirmation is not required: the pattern itself is a confirmation to the bear Engulfing |
//------ // Three Outside Up the bull model if(cand1.trend==DOWN && !cand1.bull && cand2.trend==DOWN && cand2.bull && cand3.bull && // check the trend direction and direction of the candlestick cand2.bodysize>cand1.bodysize && // the body of the second candlestick is larger than that of the first cand3.close>cand2.close) // the third day is closed higher than the second { comment=_language?"Three Outside Up"; if(_forex)// if forex { if(cand1.close>=cand2.open && cand1.open<cand2.close) // the body of the first candlestick is inside the body of the second { DrawSignal(prefix+"Three Outside Up the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } else { if(cand1.close>cand2.open && cand1.open<cand2.close) // the body of the first candlestick is inside the body of the second { DrawSignal(prefix+"Three Outside Up the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } } // Three Outside Down the bear model if(cand1.trend==UPPER && cand1.bull && cand2.trend==UPPER && !cand2.bull && !cand3.bull && // check the trend direction and direction of the candlestick cand2.bodysize>cand1.bodysize && // the body of the second candlestick is larger than that of the first cand3.close<cand2.close) // the third day is closed lower than the second { comment=_language?"Three Outside Down"; if(_forex)// if forex { if(cand1.close<=cand2.open && cand1.open>cand2.close) // the body of the first candlestick is inside the body of the second { DrawSignal(prefix+"Three Outside Down the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } else { if(cand1.close<cand2.open && cand1.open>cand2.close) // the body of the first candlestick is inside the body of the second { DrawSignal(prefix+"Three Outside Down the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Three Inside Up (bullish) |
Buy |
Downward trend. In the first two sessions the Harami (bull) pattern is formed: a small white body is engulfed by a large black one. Close in the third session is higher than High of the first two candlesticks. Confirmation is not required: the pattern itself is a confirmation to the bull Harami. | ||
Three Inside Down (bearish) |
Sell |
Uptrend. In the first two sessions the Harami (bear) pattern is formed: a small black body is engulfed by a large white one. Close in the third session is lower than Low of the first two candlesticks. Confirmation is not required: the pattern itself is a confirmation to the bear Harami. |
//------ // Three Inside Up the bull model if(cand1.trend==DOWN && !cand1.bull && cand2.bull && cand3.bull && //check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && //checking the "long" candlestick cand1.bodysize>cand2.bodysize && // the body of the first candlestick is larger than that of the second one cand3.close>cand2.close) // the third day closes higher than the second { comment=_language?"Three Inside Up"; if(_forex)// if forex { if(cand1.close<=cand2.open && cand1.close<=cand2.close && cand1.open>cand2.close) // the body of the second candlestick is inside the body of the first one { DrawSignal(prefix+"Three Inside Up the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } else { if(cand1.close<cand2.open && cand1.close<cand2.close && cand1.open>cand2.close) // the body of the second candlestick is inside the body of the first one { DrawSignal(prefix+"Three Inside Up the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } } // Three Inside Down the bear model if(cand1.trend==UPPER && cand1.bull && !cand2.bull && !cand3.bull &&//check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick cand1.bodysize>cand2.bodysize && // the body of the first candlestick is larger than that of the second one cand3.close<cand2.close) // the third day closes lower than the second { comment=_language?"Three Inside Down"; if(_forex)// if forex { if(cand1.close>=cand2.open && cand1.close>=cand2.close && cand1.close>=cand2.close) // inside the body of the first candlestick { DrawSignal(prefix+"Three Inside Down the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } else { if(cand1.close>cand2.open && cand1.close>cand2.close && cand1.open<cand2.close) // inside the body of the first candlestick { DrawSignal(prefix+"Three Inside Down the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Three Stars (bullish) |
Buy |
Downward trend. The gap between the first doji and previous candlesticks is not required. All the three candlesticks are doji. The middle doji has a gap up or down. Forex: all the three doji are on one level. Confirmation is suggested. | ||
Three Stars (bearish) |
Sell |
Uptrend. The gap between the first doji and previous candlesticks is not required. All the three candlesticks are doji. The middle doji has a gap up or down. Forex: all the three doji are on one level. Confirmation is suggested. |
//------ // Three Stars the bull model if(cand1.trend==DOWN && // check the trend direction cand1.type==CAND_DOJI && cand2.type==CAND_DOJI && cand3.type==CAND_DOJI) // check doji { comment=_language?"Bullish Three Stars"; if(_forex)// if forex { DrawSignal(prefix+"Three Stars the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } else { if(cand2.open!=cand1.close && cand2.close!=cand3.open) // the second candlestick is on a different level { DrawSignal(prefix+"Three Stars the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } } // Three Stars the bear model if(cand1.trend==UPPER && // check the trend direction cand1.type==CAND_DOJI && cand2.type==CAND_DOJI && cand3.type==CAND_DOJI) // check doji { comment=_language?"Bearish Three Stars"; if(_forex)// if forex { DrawSignal(prefix+"Three Stars the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } else { if(cand2.open!=cand1.close && cand2.close!=cand3.open) // the second candlestick is on a different level { DrawSignal(prefix+"Three Stars the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Identical Three Crows (bearish) |
Sell |
Uptrend. Three long black candlesticks appear one after another, close prices of each of them is lower than that of the previous. The open price of each crow is approximately equal to Close of the preceding candlestick. The lower shadows of the crows are short. Confirmation is not required. |
// Identical Three Crows the bear model if(cand1.trend==UPPER && !cand1.bull && !cand2.bull && !cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // checking the "long" candlestick or marubozu (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG)) // checking the "long" candlestick or marubozu { comment=_language?"Identical Three Crows"; if(_forex)// if forex { DrawSignal(prefix+"Identical Three Crows the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } else // a different market { if(cand1.close>=cand2.open && cand2.close>=cand3.open) // open is less or equal to close of the preceding candlestick { DrawSignal(prefix+"Identical Three Crows the bear model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Unique Three River Bottom (bullish) |
Buy |
The pattern is not implemented |
Downward trend. The first candlestick of the model is a long black with short shadows. On the second day Harami appears, but with a black body. The lower shadow of the second day gives a new Low. The third day is a short white day lower than the middle day. Confirmation is not necessary but desirable. |
// Unique Three River Bottom the bull model if(cand1.trend==DOWN && !cand1.bull && !cand2.bull && cand3.bull && // check the trend direction and the candlestick direction (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && cand3.type==CAND_SHORT && // check the "long" candlestick or "marubozu" third short day cand2.open<cand1.open && cand2.close>cand1.close && cand2.low<cand1.low && // body of the second candlestick is inside the first, Low is lower than the first cand3.close<cand2.close) // the third candlestick is below the second { comment=_language?"Unique Three River Bottom"; if(!_forex)// non-forex { DrawSignal(prefix+"Unique Three River Bottom the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } }
3.1.4. Patterns consisting of four candlesticks
/* Checking patterns with four candlesticks */ CANDLE_STRUCTURE cand4; cand4=cand3; cand3=cand2; cand2=cand1; if(!RecognizeCandle(_Symbol,_Period,time[i-3],InpPeriodSMA,cand1)) continue;
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Concealing Baby Swallow (bull) |
Buy |
The pattern is not implemented |
Downward trend. The first two sessions are two black marubozu. The third session opens with a break down, but trade is conducted inside the body of the second candlestick, which leads to the formation of a long upper shadow. The fourth black candlestick completely engulfs the third one, including the shadow. Confirmation is not required. |
//------ // Concealing Baby Swallow the bull model if(cand1.trend==DOWN && !cand1.bull && !cand2.bull && !cand3.bull && !cand4.bull && // check the trend direction and the candlestick direction cand1.type==CAND_MARIBOZU_LONG && cand2.type==CAND_MARIBOZU_LONG && cand3.type==CAND_SHORT && // checking "marubozu" cand3.open<cand2.close && cand3.high>cand2.close && // third candlestick with a gap down, High is inside the 2nd candlestick cand4.open>cand3.high && cand4.close<cand3.low) // the fourth candlestick completely engulfs the third { comment=_language?"Concealing Baby Swallow"; if(!_forex)// non-forex { DrawSignal(prefix+"Concealing Baby Swallow the bull model"+string(objcount++),cand1,cand2,cand4,InpColorBull,comment); } }
3.1.5. Patterns consisting of two candlesticks
/* Checking patterns with five candlesticks */ CANDLE_STRUCTURE cand5; cand5=cand4; cand4=cand3; cand3=cand2; cand2=cand1; if(!RecognizeCandle(_Symbol,_Period,time[i-4],InpPeriodSMA,cand1)) continue;
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Breakaway (bullish) |
Buy |
The pattern is not implemented |
Downward trend. The first two sessions — a "long" black candlestick and a "short" black candlestick (star) with a gap. The third session is "short", can be of any color. The fourth candlestick is "Short" black. The fifth one is "long" white with Close inside the gap. Confirmation is suggested. | |
Breakaway (bearish) |
Sell |
The pattern is not implemented |
Uptrend. The first two sessions — a "long" white candlestick and a "short" white candlestick (star) with a gap. The third session is a "short" candlestick, can be of any color. The fourth day is "short" white. The fifth one is "long" black with Close inside the gap. Confirmation is suggested. |
//------ // Breakaway the bull model if(cand1.trend==DOWN && !cand1.bull && !cand2.bull && !cand4.bull && cand5.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG|| cand1.type==CAND_MARIBOZU_LONG) && //checking the "long" first candlestick cand2.type==CAND_SHORT && cand2.open<cand1.close && // the second is "short", separated from the first cand3.type==CAND_SHORT && cand4.type==CAND_SHORT && // third and fourth are "short" (cand5.type==CAND_LONG || cand5.type==CAND_MARIBOZU_LONG) && cand5.close<cand1.close && cand5.close>cand2.open) // fifth is "long" white with close inside the gap { comment=_language?"Bullish Breakaway"; if(!_forex)// non-forex { DrawSignal(prefix+"Breakaway the bull model"+string(objcount++),cand1,cand2,cand5,InpColorBull,comment); } } // Breakaway the bear model if(cand1.trend==UPPER && cand1.bull && cand2.bull && cand4.bull && !cand5.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG|| cand1.type==CAND_MARIBOZU_LONG) && // checking the "long" first candlestick cand2.type==CAND_SHORT && cand2.open<cand1.close && // the second is "short", separated from the first cand3.type==CAND_SHORT && cand4.type==CAND_SHORT && // third and fourth are "short" (cand5.type==CAND_LONG || cand5.type==CAND_MARIBOZU_LONG) && cand5.close>cand1.close && cand5.close<cand2.open) // fifth is "long" black with close inside the gap { comment=_language?"Bearish Breakaway"; if(!_forex)// non-forex { DrawSignal(prefix+"Breakaway the bear model"+string(objcount++),cand1,cand2,cand5,InpColorBear,comment); } }
3.2. CONTINUATION PATTERNS
Continuation patterns are the time when the market is resting.
Whatever the model, you need to make a decision about your current position, even if it is to change nothing.
3.2.1. Patterns consisting of a single candlestick
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Kicking (bullish) |
Buy |
The pattern is not implemented |
The black "marubozu" is followed by the white "marubozu". There is a gap between the bodies. Confirmation is not required. | |
Kicking (bearish) |
Sell |
The pattern is not implemented |
The white "marubozu" is followed by the black "marubozu". There is a gap between the bodies. Confirmation is not required. |
//------ // Kicking the bull model if(!cand1.bull && cand2.bull && // check the trend direction and direction of the candlestick cand1.type==CAND_MARIBOZU_LONG && cand2.type==CAND_MARIBOZU_LONG && // two marubozu cand1.open<cand2.open) // a gap between them { comment=_language?"Bullish Kicking"; if(!_forex)// if non-forex { DrawSignal(prefix+"Kicking the bull model"+string(objcount++),cand1,cand2,InpColorBull,comment); } } // Kicking the bear model if(cand1.bull && !cand2.bull && // check the trend direction and direction of the candlestick cand1.type==CAND_MARIBOZU_LONG && cand2.type==CAND_MARIBOZU_LONG && // two marubozu cand1.open>cand2.open) // a gap between them { comment=_language?"Bearish Kicking"; if(!_forex)// if non-forex { DrawSignal(prefix+"Kicking the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } }
3.2.2. Patterns consisting of two candlesticks
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Bearish On Neck Line |
Sell |
The pattern is not implemented |
Downward trend. The first candlestick of the pattern is long black. The white candlestick closes below Low of the black one and closes at about Low of the black candlestick. The white candlestick - not necessarily a long day. Confirmation is suggested. | |
In Neck Line (bearish) |
Sell |
The pattern is not implemented |
Downward trend. The first candlestick of the pattern is long black. The white candlestick opens below Low of the black one and closes a little higher than Close of the black candlestick. The white candlestick - not necessarily a long day. The body of the white candlestick is smaller than the body of the black candlestick. The upper shadow of the white candlestick is very small. Confirmation is suggested. | |
Thrusting Line (bearish) |
Sell |
The pattern is not implemented |
Downward trend. The first candlestick of the pattern is long black. The white candlestick opens below Low of the black one and closes a higher than Close of the black candlestick, but the close price is still below the middle of the black candlestick. The white candlestick - not necessarily a long day. Confirmation is suggested. |
These three models have much in common, so their implementation is somewhat different, please pay attention to it.
//------ Check On Neck patterns if(cand1.trend==DOWN && !cand1.bull && cand2.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG)) // the first candlestick is "long" { // On Neck Line the bear model if(cand2.open<cand1.low && cand2.close==cand1.low) // the second candlestick opens below 1st and closes at Low of the first { comment=_language?"On Neck Line Bear"; if(!_forex)// if not forex { DrawSignal(prefix+"On Neck Line the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } else { // In Neck Line the bear model if(cand1.trend==DOWN && !cand1.bull && cand2.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && // the first candlestick is "long" cand1.bodysize>cand2.bodysize && // body of 2nd candlestick is smaller than that of the 1st one cand2.open<cand1.low && cand2.close>=cand1.close && cand2.close<(cand1.close+cand1.bodysize*0.01)) // the second candlestick opens lower than first and closes a little higher than Close of the first { comment=_language?"In Neck Line Bear"; if(!_forex)// если не форекс { DrawSignal(prefix+"In Neck Line the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } else { // Thrusting Line the bear model if(cand1.trend==DOWN && !cand1.bull && cand2.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && // the first candlestick is "long" cand2.open<cand1.low && cand2.close>cand1.close && cand2.close<(cand1.open+cand1.close)/2) // the second candlestick opens lower than first and closes a higher than Close of the first but lower than middle { comment=_language?"Thrusting Line Bea"; if(!_forex)// if non-forex { DrawSignal(prefix+"Thrusting Line the bear model"+string(objcount++),cand1,cand2,InpColorBear,comment); } } } } }
3.2.3. Patterns consisting of three candlesticks
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Upside Gap Three Methods (bullish) |
Buy |
The pattern is not implemented |
Uptrend. The first two candlesticks are two "long" white candlesticks with a gap. The third candlestick opens inside the body of the second and fills in the gap. Confirmation is suggested. | |
Upside Gap Three Methods (bearish) |
Sell |
The pattern is not implemented |
Downward trend. The first two candlesticks are two "long" black candlesticks with a gap. The third candlestick opens inside the body of the second and fills in the gap. Confirmation is suggested. |
//------ // Upside Gap Three Methods the bull model if(cand1.trend==UPPER && cand1.bull && cand2.bull && !cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // the first two candlesticks are "long" cand2.open>cand1.close && // a gap between the first and the second cand3.open>cand2.open && cand3.open<cand2.close && cand3.close<cand1.close) // the third candlestick opens inside the body of the second and fills in the gap { comment=_language?"Upside Gap Three Methods"; if(!_forex)// non-forex { DrawSignal(prefix+"Upside Gap Three Methods the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } //------ // Downside Gap Three Methods the bull model if(cand1.trend==DOWN && !cand1.bull && !cand2.bull && cand3.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // the first two candlesticks are "long" cand2.open<cand1.close && // a gap between the first and the second cand3.open<cand2.open && cand3.open>cand2.close && cand3.close>cand1.close) //the third candlestick opens inside the body of the second and fills in the gap { comment=_language?"Downside Gap Three Methods"; if(!_forex)// non-forex { DrawSignal(prefix+"Downside Gap Three Methods the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } }
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Upside Tasuki Gap (bullish) |
Buy |
< |
The pattern is not implemented |
Uptrend. The gap between two neighboring white candles. White candlesticks are not necessarily "long". The third session opens within the body of the second candlestick. The third session closes inside the gap, but the gap is partially unfilled. Confirmation is suggested. |
Downside Tasuki Gap (bearish) |
Sell |
The pattern is not implemented |
Downward trend. The gap between two neighboring black candles. Black candlesticks are not necessarily "long". The third session opens within the body of the second candlestick. The third session closes inside the gap, but the gap is partially unfilled. Confirmation is suggested. |
//------ // Upside Tasuki Gap the bull model if(cand1.trend==UPPER && cand1.bull && cand2.bull && !cand3.bull && // check the trend direction and direction of the candlestick cand1.type!=CAND_DOJI && cand2.type!=CAND_DOJI && // the first two candlesticks are not doji cand2.open>cand1.close && // a gap between the first and the second cand3.open>cand2.open && cand3.open<cand2.close && cand3.close<cand2.open && cand3.close>cand1.close) // 3rd candlestick opens inside 2nd and closes inside the gap { comment=_language?"Upside Tasuki Gap"; if(!_forex)// non-forex { DrawSignal(prefix+"Upside Tasuki Gap the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBull,comment); } } //------ // Downside Tasuki Gap the bull model if(cand1.trend==DOWN && !cand1.bull && !cand2.bull && cand3.bull && // check the trend direction and direction of the candlestick cand1.type!=CAND_DOJI && cand2.type!=CAND_DOJI && // the first two candlesticks are not doji cand2.open<cand1.close && // a gap between the first and the second cand3.open<cand2.open && cand3.open>cand2.close && cand3.close>cand2.open && cand3.close<cand1.close) // 3rd candlestick opens inside 2nd and closes inside the gap { comment=_language?"Downside Tasuki Gap"; if(!_forex)// non-forex { DrawSignal(prefix+"Downside Tasuki Gap the bull model"+string(objcount++),cand1,cand2,cand3,InpColorBear,comment); } }
3.2.4. Patterns consisting of four candlesticks
Name of the Pattern | Order | Classical pattern | Forex | Pattern recognition |
---|---|---|---|---|
Three-Line Strike (bullish) |
Buy |
The bullish trend is continuing with three candlesticks, similar to the Three white soldiers pattern: long white candlesticks with short shadows. Forex: Open/close prices of white candlesticks are the same. The fourth candlestick opens with a gap up and closes below open of the first white candlestick. Forex: close of 3rd and open of 4tha candlesticks are equal. Confirmation is suggested. | ||
Three-Line Strike (bearish) |
Sell |
The bearish trend is continuing with three candlesticks, similar to the Three black crows pattern: long black candlesticks with short shadows. Forex: Open/close prices of black candlesticks are the same (similar to Identical three crows). The fourth candlestick opens with a gap down and closes above open of the first black candlestick. Forex: close of 3rd and open of 4tha candlesticks are equal. Confirmation is suggested. |
//------ // Three-line strike the bull model if(cand1.trend==UPPER && cand1.bull && cand2.bull && cand3.bull && !cand4.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // check the "long: candlestick or "maruozu" (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // check the "long: candlestick or "maruozu" cand2.close>cand1.close && cand3.close>cand2.close && cand4.close<cand1.open) // close of 2nd is higher than 1st, that of 3rd is higher than 2nd, the fourth candlestick closes lower than the 1st { comment=_language?"Three-line strike"; if(_forex)// if forex { if(cand4.open>=cand3.close) // 4th opens higher than the 3rd { DrawSignal(prefix+"Three-line strike the bull model"+string(objcount++),cand1,cand3,cand4,InpColorBull,comment); } } else // a different market { if(cand4.open>cand3.close) // 4th opens higher than th 3rd { DrawSignal(prefix+"Three-line strike the bull model"+string(objcount++),cand1,cand3,cand4,InpColorBull,comment); } } } //------ // Three-line strike the bear model if(cand1.trend==DOWN && !cand1.bull && !cand2.bull && !cand3.bull && cand4.bull && // check the trend direction and direction of the candlestick (cand1.type==CAND_LONG || cand1.type==CAND_MARIBOZU_LONG) && (cand2.type==CAND_LONG || cand2.type==CAND_MARIBOZU_LONG) && // check the "long: candlestick or "maruozu" (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU_LONG) && // check the "long: candlestick or "maruozu" cand2.close<cand1.close && cand3.close<cand2.close && cand4.close>cand1.open) // close of 2nd is lower than 1st, close of 3rd is lower than 2nd, the fourth candlestick closes higher than 1st { comment=_language?"Three-line strike"; if(_forex)// if forex { if(cand4.open<=cand3.close) // the fourth opens lower than or equal to the third { DrawSignal(prefix+"Three-line strike the bear model"+string(objcount++),cand1,cand3,cand4,InpColorBear,comment); } } else // a different market { if(cand4.open<cand3.close) // the fourth opens lower than 3rd { DrawSignal(prefix+"Three-line strike the bear model"+string(objcount++),cand1,cand3,cand4,InpColorBear,comment); } } }
4. The implementation of the indicator
Let's select required input parameters.
Figure 3. Input parameters of the Candlestick Patterns indicator
The first parameter is the "Averaging period" - we need it for determining trend direction, defining "long" and "short" candlesticks.
The next parameter is "Enable signal" - responsible for enabling/disabling the signal. The signal notifies that anew pattern has appeared.
Figure 4. Signals generated by the Candlestick Patterns indicator
Parameter "Number of bars for calculation" is designed to facilitate the work of the indicator. If its value is less or equal to 0 candlestick patterns are searched through the entire available history, otherwise a set number of bars is used for search, which considerably facilitates the work of the indicator.
I think everything is clear with colors...
"Enable comments" means enable/disable names of candlestick patterns.
"Font size" sets the font size for comments.
The implementation of the indicator is very simple.
Expect the appearance of a new bar:
//--- Wait for a new bar if(rates_total==prev_calculated) { return(rates_total); }
Then we calculate the initial value of the counter to start the cycle.
int limit; if(prev_calculated==0) { if(InpCountBars<=0 || InpCountBars>=rates_total) limit=InpPeriodSMA*2; else limit=rates_total-InpCountBars; } else limit=prev_calculated-1;
In the loop we check the combinations of candlesticks and display them as it shown in Fig. 5:
- Combination with one candlestick: an arrow with the pattern name above or below it.
- Combination with two candlesticks: a thin rectangle with the pattern name above or below the first candlestick.
- Combination with three or more candlesticks: a thick rectangle with the pattern name above or below the last candlestick.
Figure 5. Example of how the Candlestick Patterns indicator works
Please note that due to the possibility of function overloading, the output of signs of different patterns is done via the functions with the same name DrawSignal(), but with different numbers of parameters.
void DrawSignal(string objname,CANDLE_STRUCTURE &cand,color Col,string comment)
void DrawSignal(string objname,CANDLE_STRUCTURE &cand1,CANDLE_STRUCTURE &cand2,color Col,string comment)
void DrawSignal(string objname,CANDLE_STRUCTURE &cand1,CANDLE_STRUCTURE &cand2,CANDLE_STRUCTURE &cand3,color Col,string comment)
The full text of the indicator is in the file Candlestick_Patterns.mq5 attached to this article.
Conclusion
In this article we have reviewed most of the candlestick patterns, methods of detecting them and provided examples of how to implement them in the MQL5 programming language. The attachment to the article contains two indicators and an include file. To use them, place indicators in the \Indicators folder and include file in \Include folder, then compile them.
I hope that the analysis of candlestick patterns will help you improve the results of your work.
Looking ahead, I'd like to add that filtered out candlesticks give better results than most of technical indicators, but we will consider this subject in the following article, in which I am going to create a trading system and an Expert Advisor trading by the candlestick patterns.
Translated from Russian by MetaQuotes Ltd.
Original article: https://www.mql5.com/ru/articles/101
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have a question about "ANALYZING CANDLESTICK PATTERNS"
Is it possible to apply the filter "candlestickPatter" to an indicator that creates candles ?
thx,
Davide
Hi,
How could I use this indicator ("ANALYZING CANDLESTICK PATTERNS") in my EA? is there any buffer to capture the information?
Thanks a lot.
Eduardo
Hi,
How could I use this indicator ("ANALYZING CANDLESTICK PATTERNS") in my EA? is there any buffer to capture the information?
Thanks a lot.
Eduardo
I used rectangle counters and from these counters create a buffer to buy and another to sell. The results are very interesting, especially when applying filter indicators.
This is a great tutorial. Please How can I get the candle types to work with buffers for my EA... someone help please