## Candlestick pattern analysis in MATLAB

Help
2011-06-21
2013-04-26
• Aveshen Pillay - 2011-06-21

Hi there,

I have recently started using the TA-Lib and it is excellent. I am however, having some difficulty using the candlestick recognition functions. Specifically, I am not sure how to interpret the output from the functions.

In MATLAB, I have a candlestick plot of my entire stock price history and I then use the candlestick functions to recognise the patterns. As an example for the three inside up/down function (TA_CDL3INSIDE), I get 0’s and then a100 at one specific point. Does that mean that there should be that candlestick pattern at that point? Drawing a candlestick graph around the point does not look like what it should.

Any assistance in understanding how to interpret the output from the candle stick functions is most appreciated. What does the integer output signal? Should it be persistent, or does one point that yields non-zero signal a pattern.

I have tried to understand the source code in C++, but found it quite difficult as my knowledge of C++ is quite limited.

Thank you very much.

• r_pankevicius - 2011-08-10

Hi,

I took a look at C code and got tired very soon of many macros (#defines) used there. However, here are facts about TA_CDL3INSIDE as I understood it.

1. It requires more than 12 inputs for some candle setup. (So called "minimal lookback range").
2. It returns array of N-12 elements in outInteger with signals starting from 12th element. (Don't stick with 12, use outBegIdx that will be 12 at return and outNBElement that will be N-12. This is a general way to interpret ta-lib outputs).
3. There are 3 possible values in output: 0 - no signal, 100 for 3rd candle confirming "three inside up" pattern, -100 for 3rd candle confirming "three inside down" pattern.

Warning: The user should consider that a three inside up is significant when it appears in a downtrend and a three inside down is significant when it appears in an uptrend, while this function does not consider the trend.

Two examples. 1st one makes three inside up pattern at elements 14,15,16. 2nd one is a mirror of first around price axis 100 what gives 3 inside down confirmation. outInteger should be matched against input data starting from Start index (6 elements at 12-17). 4th element in outInteger is 100/-100 what gives signal confirmation at index 12+4=16.

``` === Input:
Idx  Open High Low Close
0, 100, 100, 100, 100
1, 100, 100, 100, 100
2, 100, 100, 100, 100
3, 100, 100, 100, 100
4, 100, 100, 100, 100
5, 100, 100, 100, 100
6, 100, 100, 100, 100
7, 100, 100, 100, 100
8, 100, 100, 100, 100
9, 100, 100, 100, 100
10, 100, 100, 100, 100
11, 100, 100, 100, 100
12, 100, 100, 100, 100
13, 100, 105,  85,  90
14,  80,  90,  65,  70
15,  74,  80,  60,  76
16,  75,  95,  70,  90
17, 100, 110,  90, 100
=== Result from Cdl3Inside:
Start index: 12
NB element : 6
outInteger[6] : 0 0 0 0 100 0
=== Input:
Idx  Open High Low Close
0, 100, 100, 100, 100
1, 100, 100, 100, 100
2, 100, 100, 100, 100
3, 100, 100, 100, 100
4, 100, 100, 100, 100
5, 100, 100, 100, 100
6, 100, 100, 100, 100
7, 100, 100, 100, 100
8, 100, 100, 100, 100
9, 100, 100, 100, 100
10, 100, 100, 100, 100
11, 100, 100, 100, 100
12, 100, 100, 100, 100
13, 100, 115,  95, 110
14, 120, 135, 110, 130
15, 126, 140, 120, 124
16, 125, 130, 105, 110
17, 100, 110,  90, 100
=== Result from Cdl3Inside:
Start index: 12
NB element : 6
outInteger[6] : 0 0 0 0 -100 0
```