Creating a Binance Futures Trading Strategy with Japanese Candlestick Signals: A Step-by-Step Guide

Artem Stepanenko
5 min readDec 7, 2023

--

This article begins a series of publications on the results of a project to create a trading robot for the Binance futures market based on Japanese candlestick patterns. The author’s task was to develop trading strategies and adapt them to the technological features of the Binance trading platform.

Candlestick Chart

Despite its initial simplicity, the implementation of the task became more multifaceted and non-trivial as the project progressed. Approaches honed through iterations of trial and error allowed for the formation of a technology for developing, testing, and auditing trading strategies for a wide range of algorithmic systems. Let’s examine this technology step by step and through specific examples.

Step One — Formalizing the Patterns

To implement any trading ideas based on Japanese candlesticks, it is first necessary to define what we consider to be candlestick patterns, by what criteria we identify them, and how we distinguish one pattern from another.

Trying Third-Party Libraries

At first glance, the solution might seem to lie in using already developed libraries (like TA-Lib or Japanese-Candlestick, which have this functionality). However, a closer examination reveals that these third-party libraries are unsuitable for developing our own trading strategies due to their “black box” nature.

How a library defines a pattern, how it correlates them with each other, what default proportions/parameters/characteristics are embedded, and what can be customized for analysis purposes? All this is hidden “under the hood” and is not accessible for customization. Additionally, available libraries contain arbitrary sets of patterns and do not complement each other, let alone provide comparable results.

It’s clear that this path is not viable: we lose control over our trading system and lack the tools for its optimization.

Creating Our Own Library of Japanese Candlestick Patterns

To effectively manage our trading system, the only option is to develop our own library of Japanese candlestick patterns, as they are the foundation of our trading strategies.

An analysis of popular literature in the professional community showed that traders distinguish more than 60 patterns with their stable designations and distinctive characteristics. However, there is no unified database of Japanese candlesticks — it must be compiled independently.

Moreover, most pattern descriptions are quite general. For instance, the description of the Hammer pattern: “The Hammer is a candlestick with a small body and a long lower shadow. The upper shadow, if present, should be short”. This raises the question of formalization — we need to define what we consider a “small body”, “long body”, or “short shadow, if present”. Obviously, certain deviations from the standard must be anticipated: there are no perfect candlesticks, nor should we chase them; instead, our interest lies in finding exchange chart segments most closely matching the pattern description.

Additionally, when developing a library of Japanese candlestick patterns, it’s necessary to consider the peculiarities of trading futures on Binance, where trading occurs 24/7 without pauses in chart formation. Consequently, there are almost no gaps in the closing and opening prices, and the opening of the subsequent candle always coincides with the closing of the previous one. This requires modifying almost all Japanese candlestick patterns that describe price behaviour in situations with an opening gap (Morning or Evening Star, Island Reversal Gap) and other situations of non-coincidence of opening and closing prices (Harami, Engulfing).

As a result, we selected 34 Japanese candlestick patterns that can be adapted to the specifics of trading Binance futures without losing their original idea. The established rules for tolerances and deviations allow for the regular appearance of patterns on the Binance futures charts.

List of Selected Patterns

What was left out? We had to abandon some patterns for several reasons:

a) Due to the specifics of 24/7 trading chart formation, some patterns will never form. For example, the Bullish Homing Pigeon, where the second candle defining the pattern should have an opening price significantly lower than the opening price of the previous candle. Since gaps are almost non-existent in round-the-clock trading, expecting such a pattern to appear, especially on smaller timeframes, is unrealistic.

b) Some patterns are merely specific cases of more common patterns. For example, Dragonfly Doji, which can be a specific case of either Black Hammer or White Hanging Man, depending on the assumptions made about the length of the candle body. Accordingly, we will test the effectiveness of the Dragonfly Doji when analysing the effectiveness of the main patterns.

Examples of the Excluded Patterns

Identifying Groups of Properties for Classifying Japanese Candlesticks

After selecting the patterns, it is necessary to identify common properties of the selected patterns, formulate rules for their determination, and assign a range of acceptable values to each property.

For example, “long shadow” is mentioned in all sources, but “long” is understood differently by everyone: somewhere, it is suggested to consider this as 3 or 4 lengths of the average candle’s length over some past period, elsewhere it is tied to the length of the candle’s body itself. Moreover, for some patterns, the “long shadow” parameter is necessary, while for others it is redundant.

For the 34 selected patterns, the following properties were identified:

List of Properties

Coding Patterns and Forming Our Own Library of Japanese Candlesticks

Now, we describe each of the selected patterns using standardized properties. We do this in Python utilising the Pandas library, whose vectorized computations will significantly reduce the time for subsequent trading hypothesis testing and back-testing.

Below is an example of describing the Bullish In-Trend Marubozu pattern.

Bullish In-Trend Marubozu Python’s Function

Using a similar approach, we will form our own library of Japanese candlesticks, defining all the selected patterns on the price chart. By using vectorized calculations and standardized parameters, we can be confident that our library will work efficiently with large data volumes.

Step One Outcome and Moving Forward

Now we can claim that we have a tool that uniformly sees the entire Binance futures market (over 200 traded pairs 24/7), and it does so in all available Binance timeframes. With such a foundation, we can move on to the next step — creating trading strategies using Japanese candlestick patterns.

However, to reach the launch of the trading robot in production, the following tasks still need to be addressed:

Stay tuned as we tackle these challenges and move towards launching our trading robot.

Thank you for reading! Your comments and feedback are greatly appreciated.

--

--