# Do candlestick patterns work on their own? A systematic FX back-test using Python.

## Approaching candlesticks in a systematic way.

Throughout the huge field of pattern recognition trading, we find some very popular technical patterns that always come up in every technical analysis class, but do they really work? That is, on their own. Remember that, when we say a bullish candle, we refer to a green-colored (or a white one) one and the same thing goes with bearish candles (red or black body).

• The second candle has a small body that does not touch the first candle’s body.
• The third candle should be bullish and should have a body that is inside the first candle’s body.
• The second candle has a small body that does not touch the first candle’s body.
• The third candle should be bearish and should have a body that is inside the first candle’s body.

# BACK-TESTING SOME OF THE PATTERNS

The below back-tests are on the GBPUSD pair hourly time frame using a 1 pip transaction cost, and a 7-hour holding period. The dataset is of the OHLC type.

`# Key conditionsfor i in range(len(Data)):  if Data[i, 3] == Data[i, 0] and Data[i, 3] < Data[i — trend, 3]:    Data[i + 1, 4] = 1for i in range(len(Data)):  if Data[i, 3] == Data[i, 0] and Data[i, 3] > Data[i — trend, 3]:    Data[i + 1, 5] = -1# Position triggerfor i in range(len(Data)):  if Data[i, 4] == 1:   Data[i, 6] = 1  if Data[i, 5] == -1:   Data[i, 7] = -1`
`# Key conditionsfor i in range(len(Data)):  if Data[i, 3] > Data[i, 0] and Data[i — 1, 3] > Data[i — 1, 0] and \ Data[i — 2, 3] > Data[i — 2, 0]:    Data[i + 1, 4] = 1for i in range(len(Data)):  if Data[i, 3] < Data[i, 0] and Data[i — 1, 3] < Data[i — 1, 0] and \ Data[i — 2, 3] < Data[i — 2, 0]:    Data[i + 1, 5] = -1# Position triggerfor i in range(len(Data)):  if Data[i, 4] == 1:    Data[i, 6] = 1  if Data[i, 5] == -1:    Data[i, 7] = -1`
`# Key conditionsfor i in range(len(Data)):  if Data[i, 0] < Data[i — 1, 3] and Data[i, 3] > Data[i — 1, 3] and \ Data[i, 3] < Data[i — 1, 0]:    Data[i + 1, 4] = 1for i in range(len(Data)):  if Data[i, 0] > Data[i — 1, 3] and Data[i, 3] < Data[i — 1, 3] and \ Data[i, 3] > Data[i — 1, 0]:    Data[i + 1, 5] = -1# Position triggerfor i in range(len(Data)):  if Data[i, 4] == 1:    Data[i, 6] = 1  if Data[i, 5] == -1:    Data[i, 7] = -1`
`# Key conditionsfor i in range(len(Data)):  if Data[i — 1, 0] == Data[i — 1, 3] and \ Data[i — 2, 3] < Data[i — 2, 0] and \ Data[i, 3] > Data[i, 0] and \ Data[i — 1, 0] < Data[i — 2, 3] and \ Data[i — 1, 0] < Data[i, 0]:    Data[i + 1, 4] = 1for i in range(len(Data)):  if Data[i — 1, 0] == Data[i — 1, 3] and \ Data[i — 2, 3] > Data[i     — 2, 0] and \ Data[i, 3] < Data[i, 0] and \ Data[i — 1, 0] > Data[i — 2, 3] and \ Data[i — 1, 0] > Data[i, 0]:    Data[i + 1, 5] = -1# Position triggerfor i in range(len(Data)):  if Data[i, 4] == 1:    Data[i, 6] = 1  if Data[i, 5] == -1:    Data[i, 7] = -1`

Written by