Explaining and back-testing the Ichimoku Kinko Hyo in trading using Python.

Ichimoku Kinko Hyo or Ichimoku is not just a strategy, but a full trading system. It builds on price bars to generate its signals. Developed around the late 1930’s by Goichi Hosoda, the system grew to be widely popular in Japan and other locations around the world. It has been quoted as being hard to understand due to its many displays on the chart, but we will soon see that approaching it step by step will make it a crystal-clear indicator. The name Ichimoku Kinko Hyo means instant look at the cloud chart (also known as equilibrium chart) and this comes from the fact that the indicator has clouds. Before we start, we will briefly present the different parts of the Ichimoku system.

  • Kijun-sen: A confirmation line that can act as a trailing stop line.
  • Tenkan-sen: A signal line that can also act as a minor support / resistance line.
  • Chikou-span: A 26-period lagged line of the actual price. Mainly used for confirmation.
  • Ichimoku cloud: This is the core of the system and it is a combination of two lines that will form a future support or resistance zone. The lines are called Senkou span A and Senkou span B. The cloud is also called Kumo.


The Kijun-sen line is used for medium-term support or resistance level. It can be trending or ranging sideways as can be seen from the below chart on the AUDNZD pair. A straight line is an indication of a flat market and thus prices crossing a straight line should not be interpreted as a trading signal, however, if prices cross a trending line, a trading signal is generated. Also, a flat Kijun-sen line can act as a price-magnet. The formula of the line is:

The formula is for the last 26 periods, hence the highest highs and lowest lows of the last 26 periods.

FIGURE Kijun-sen line acts as a resistance level. When it is flat, it pulls prices towards it.


This line is the same as the previous one, only it takes the last 9 days (or periods) of the past.

It can be used to find short-term support and resistance zones and it is conveniently used with the Kijun-sen line for crosses. In ranging markets, we can see many fake signals and hence it is better to seek out crosses in trending markets.

FIGURE Tenkan-sen line acts as a short-term support or resistance level.


Chikou-span is the lagging indicator in the Ichimoku system. It is simply the price today projected back 26 periods. It only uses the closing price and therefore does not require candlesticks for its calculation. Although its lagging nature, the Chikou-span is a good confirmation signal. It can be used in the following ways:

  • When Chikou-span crosses the price from the below, it gives a bullish signal.
  • When Chikou-span crosses the price from above, it gives a bearish signal.

Support and resistance levels can also be charted on the Chikou-span line. But we already do that with the basic charting analysis that we have seen in the first chapter, as we are merely charting the past to project the future, doing this with the Chikou-span will result in the same thing. It will be as if you were doing basic charting only 26 periods in the past, hence, we recommend using the Chikou-span as being a crossover signal generator.

FIGURE Chikou-span line. The signal is generated when the line crosses the price (of the past).


In the beautiful Japanese language, a cloud is referred to as Kumo, just as this part of the system. The true innovation of the whole Ichimoku system is the cloud. It is composed of two lines or envelopes and the cloud is the area between them. We will use that area as a support and resistance zone and the usefulness here lies in the fact that it is plotted 26 periods ahead (as opposed to the Chikou-span which is plotted 26 periods in the past). The two lines that form the cloud are called Senkou span A and Senkou span B. The formulas for both lines are pretty simple:

For the Senkou span B, the highest high and lowest low are calculated for the past 52 periods and just as the Senkou span A, it is projected 26 days into the future, so that the Ichimoku cloud is always leading the prices by 26 periods (or days if you are using a daily chart). Larger volatility forms larger clouds (denser) and they tend to be stronger when they are large as opposed to being thin. The trend is considered bullish when Senkou span A is above Senkou span B and the opposite is true. The angle is also helpful with determining the strength of the cloud. Steeper angles reinforce the conviction. Some rules of thumb regarding the Ichimoku trading system is that it is not recommended to initiate shorts above the cloud and to initiate longs below the cloud. When a breakout occurs with a thick cloud, it can be inferred that the trend has reversed. Another way of determining the reversal or stability of the trend is by monitoring the levels of the Senkou span A and Senkou span B, if they switch (which is 26 periods ahead), a new trend may commence.

FIGURE Ichimoku cloud. In grey boxes, the perfect entry points.

We have already said that Ichimoku Kinko Hyo is a full system composed of mini indicators, and so, to get a strong signal from it, we need to find a situation where all of the indicators confirm each other so that we feel comfortable entering the trade. Teamwork is essential here. For example, if we have a short signal coming from a cross between the Tenkan-sen and the Kijun-sen and prices are above the cloud, then we should not act on it because the trend is still bullish. Also, we have to be careful that the Kijun-sen is not flat when searching for trade opportunities. Although lagging in nature, we can confirm a reversal of trend if the Chikou-span crosses above prices even though 26 periods ago. Any trading system must be complete and not only give out trading signals. Risk management is important too and we can use the Ichimoku to set-up our stop-loss orders. Senkou span A and Senkou span B can help with that task. As can be seen from the previous chart, the spans can have periods in which they are flat. When we are in a winning position, we can move our stop-loss order to the flat levels. This is what we call a trailing-stop loss. Obviously, this can work wonderfully in a trending market. Now it is time to analyze all of the indicators at the same time and try to come up with meaningful confirming signals. The chart with an Ichimoku may seem to have a lot of clutter but to the trader who understands the system, it will be as simple as an empty chart.

FIGURE The Ichimoku system in a ranging market, AUDNZD. Notice the bogus signals mainly due to the thin clouds. The Ichimoku is a trend-following system.

FIGURE The intersection point of the cloud forms a good support level. Perfect entry point is in the grey box because of the alignment of all the indicators. It is better be safe than to rush in with the Ichimoku.

The next graph shows the generated signal by the Ichimoku system by following the Kumo clouds and the confirmation from the Chikou-span.

FIGURE Ichimoku signals.

Main idea: We will test whether taking positions based on the Kumo cloud is profitable or not, does it react the way we want it be? An Ichimoku strategy is not easy to establish objectively due to the many factors required to make it work. However, here is the code for the strategy with a holding period of 60. We will omit the other indicators of the Ichimoku system for now and stick to the cloud but I have provided the code for the whole system.

We will run a back-test on 6 major currencies (3H time frame to have enough data for a visible evolution). The performance metrics will be very simple and we will focus on risk-reward and accuracy through the hit ratio. The back-test is only informational as researching trading strategies is more than just back-testing known strategies through really basic performance measures.

The next graph shows the equity curve from the strategy and the results followed by the signals chart to give us a visual idea on the frequency:

Figure Equity curve following the strategy of the Kumo.

Here’s the simplified performance measurement on the currency pairs for the period between 2000 – 2020:

In conclusion, it seems, that the Ichimoku Kinko Hyo may need some tweaking. The parameters used were the default ones and some optimization can deliver better future results. Also, there were clusters of signals due to some volatility. This issue can be addressed by placing a condition on the number of open positions.

Written by

Institutional FOREX Strategist | Trader | Data Science Enthusiast. Author of the Book of Back-tests: https://www.amazon.com/dp/B089CWQWF8

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store