In this article, we will take a detailed look at Japanese candles (also known as simple in the OsEngine interface). You will learn about the history of their appearance, methods of application for trading, as well as receive a practical guide on setting up and launching this type of candles in OsEngine. Additionally, we will touch on finding the source code and calculation formula of these candles within the project.
1. History of Japanese candles.
Japanese candles appeared in the 18th century thanks to Japanese rice trader Munehisa Homma. Homma developed this method for displaying prices and market sentiments, giving him a significant advantage in rice trading. Japanese candles show the price range for a specific period, including opening price, closing price, highs, and lows. This visual tool became popular among Western traders over time due to its simplicity and informativeness. Today, Japanese candles are widely used in financial markets worldwide, helping traders analyze price patterns, predict future movements, and formulate trading strategies.
2. Calculation of this type of candles.
Step one. Choosing a price source.
There are several different types of data sources that can be used to form candles. These can be:
1. Prices from the order book of trades executed on the exchange. In this case, candles are constructed from a table of anonymous trades.
2. Prices from the order book. Sometimes candles are constructed from the center of the order book. In most cases, this is necessary. For example, in some markets, the order book is not available (forex), or market liquidity is too low to build candles from the order book. The center of the order book, bids, and asks are usually available.
Step two. Choosing the candle length in time.
This is called choosing the Timeframe. This is the time period over which we will distribute the prices of the instrument within the candle.
5 minutes, 15 minutes, 1 hour, 1 day, etc.
Step three. Price distribution within the candle.
Next, we need to distribute prices within the candle. Marking four points: Open, High, Low, Close. Also, if candles are constructed from trade order data, we can simultaneously calculate the volume that has passed during the period. Then it becomes OHLCV.
Key components of a Japanese candle:
1. Open - the price of the instrument at the beginning of the period.
2. High - the maximum price reached during the period.
3. Low - the minimum price reached during the period.
4. Close - the price of the instrument at the end of the period.
5. Volume - the volume traded during the period.
As a result, a Japanese candle is formed, showing the main four indicators (OHLC) for the selected time interval.
If the candle is green, it means the closing price was higher than the opening price. The candle is rising, and the price during the period has increased.
If the candle is red, it means the closing price was lower than the opening price. The candle is falling, and the price during the period has decreased.
3. How to trade using them. Options.
99% of all trading systems, in one way or another, are based on Japanese candles or their derivatives. Trend, countertrend, index, and pair trading strategies. In most cases, robots look at Japanese candles or indicators built on them.
This is due to their popularity in the APIs of exchanges and brokers. This is the type of candle that can usually be obtained from a trading system. And besides, it is a really great way to understand where the price is moving and how to analyze the market.
Here are a few examples of how you can use them for trading.
1. Candlestick patterns.
Repeating combinations of candles that are supposed to show where the market will go next.
1. Three green candles - buy.
2. Three red candles - sell.
3. And so on.
This is very easy to program. Literally in 10 - 50 lines of code. And you already have robots trading like insightful Japanese traders from the 18th century.
A complete list of patterns will not be provided here. If you need to try "Classic candlestick patterns" in history and trade them, then there is a great way. You can take a book, of which there are hundreds, and program what is inside them.
2. Automated search for profitable patterns.
In addition, some advanced programmers create entire stations for automatically searching for these candlestick patterns. For example, in OsEngine, this is called the "Miner":
However, you can read more about this thing in detail here.
3. Indicator strategies built on candlestick charts.
There are thousands of variations. In the same OsEngine, there are over 100 of them:
In the most basic variant, it looks like this:
1. There is a chart of Japanese candlesticks for some instrument.
2. An indicator is overlaid on top.
3. Candle movements relative to indicators are somehow analyzed. Or the indicators relative to each other.
4. Entries and exits from positions occur.
4. How to launch Japanese candles in Os Engine.
Open the main menu in Os Engine and go to "Bot Station Light".
Connect to the "Alor" connector, or any other:
Next, create a trading robot, in this case, it will be Bollinger Revers:
Now go to the menu to connect the data stream to the robot:
1. Choose a connection. In this case, it is Alor.
2. Choose the security. Sber.
3. Choose the candle type "Simple". These are Japanese candles.
4. Check or uncheck to build or not build non-trading candles.
5. Click "Accept".
After the settings, you will see the chart with "Japanese candles":
5. Where to find the source code for building Japanese candles in OsEngine.
The source code for OsEngine is open to the public on the GitHub platform.
In the project, if you open it on your PC, it can be found here:
Successful algorithms!