Introduction
The Ichimoku Kinko Hyo, often referred to as the Ichimoku Cloud, is a popular technical analysis tool used in trading. It provides a quick glance at the equilibrium of the market, offering potential buy and sell signals. This tool is widely used in technical analysis as it provides a comprehensive overview of the market conditions at a glance.
Origins
The Ichimoku Kinko Hyo was developed by a Japanese journalist, Goichi Hosoda, in the early 1940s and published in a book by him in 1968. The aim behind its development was to create an all-in-one indicator that helps traders identify the market trend, its direction, and support and resistance levels without the need for any other indicators. Over the years, it has gained popularity worldwide due to its effectiveness in different market conditions.
“Ichimoku Kinko Hyo” is a Japanese phrase that translates to “one glance equilibrium chart” in English. This name reflects the design goal of the indicator: to represent a complete picture of the market’s trend, momentum, and support and resistance levels in one glance.
Mathematical Construction of Ichimoku Kinko Hyo
The Ichimoku Kinko Hyo is composed of five main components, each calculated using high and low prices over different periods. These components are:
1. Tenkan Sen (Conversion Line): This line is calculated as the average of the highest high and the lowest low over a given period, typically the last 9 periods. The formula is:
Tenkan Sen = (9-period high + 9-period low) / 2
\text{Tenkan Sen} = \frac{\text{9-period high} + \text{9-period low}}{2}
2. Kijun Sen (Base Line): This line is similar to the Tenkan Sen but considers a longer period, usually the last 26 periods. The formula is:
Kijun Sen = (26-period high + 26-period low) / 2
\text{Kijun Sen} = \frac{\text{26-period high} + \text{26-period low}}{2}
3. Senkou Span A (Leading Span A): This line is the average of the Tenkan Sen and the Kijun Sen, plotted 26 periods ahead. The formula is:
Senkou Span A = (Tenkan Sen + Kijun Sen) / 2
\text{Senkou Span A} = \frac{\text{Tenkan Sen} + \text{Kijun Sen}}{2}
Note: This is plotted 26 periods ahead.
4. Senkou Span B (Leading Span B): This line is the average of the highest high and the lowest low over a typically longer period, usually the last 52 periods, plotted 26 periods ahead. The formula is:
Senkou Span B = (52-period high + 52-period low) / 2
\text{Senkou Span B} = \frac{\text{52-period high} + \text{52-period low}}{2}
Note: This too is plotted 26 periods ahead.
5. Chikou Span (Lagging Span): This line is the closing price of the current period, plotted 26 periods behind. The formula is:
\text{Chikou Span} = \text{Today's closing price}
Note: This is plotted 26 periods behind.
The area between Senkou Span A and Senkou Span B is known as the “cloud” or “Kumo” and provides a graphical representation of areas of support and resistance.
Please note that the periods used in these calculations can be adjusted based on the trader’s preferences and the specific characteristics of the market being traded. The standard settings (9, 26, 52) were originally chosen to reflect the typical number of business days in a week (the number 9 represents one and half times the 6 day Japanese working week), month, and two months (in Japan), but they can be adjusted to better fit other markets or trading styles.
The Ichimoku Cloud Strategy
Understanding the Ichimoku Kinko Hyo signals is crucial for developing an effective strategy. Here’s how to read the indicator’s output:
- Buy and Sell Signals: A basic Ichimoku strategy involves buy and sell signals. A buy signal occurs when the Tenkan Sen (9 period) crosses above the Kijun Sen (26 period), and the price is above the cloud. Conversely, a sell signal occurs when the Tenkan Sen crosses below the Kijun Sen, and the price is below the cloud.
- The Cloud: The cloud or Kumo is a crucial part of the Ichimoku cloud strategy. If the price is above the cloud, it indicates a bullish trend, and if it’s below the cloud, it suggests a bearish trend. The cloud can also act as a support or resistance area. The distance of the current price from the cloud however is not important nor really is the colour that some systems alternate. A thicker cloud can provide stronger support or resistance, while a thinner cloud may offer less of a barrier to price movement. The cloud’s thickness can also potentially indicate the strength of the trend.
- Chikou Span: The Chikou Span which many consider the most important line, can provide additional confirmation. If the Chikou Span line is above the price 26 periods ago, it’s a bullish sign, and if it’s below, it’s a bearish sign. Also if the Chikou span is above the cloud 26 periods ago it is bullish for today and vice versa. The 9 and 26 period moving averages can act as support and resistance for the Chikou span
Consider understanding the entire analysis in this way:
• In an upward trending market, the Chikou Span and the Clouds form a strong foundation, and above you, there’s nothing blocking the ascent;
• In a downward trending market, the Chikou Span and the dense, ominous Clouds act like a constant weight bearing down over the price action.
Pros and Cons
Like any technical analysis tool, the Ichimoku Kinko Hyo has its strengths and weaknesses. Understanding these can help traders make the most of their Ichimoku cloud strategy.
Advantages of using the Ichimoku Kinko Hyo:
- One Glance, Multiple Insights: As the name ‘Ichimoku’ suggests, which translates to ‘one look’ in English, this indicator provides a wealth of information at a glance. It can help traders identify the trend direction, gauge momentum, and find potential support and resistance levels.
- Versatility: It can be used in any market (stocks, commodities, forex, etc.) and in any timeframe, making it a versatile tool for many traders. It can be used in conjunction with other technical indicators like the Relative Strength Index (RSI) to confirm momentum in a certain direction.
- Cloud Signals: The cloud or Kumo provides dynamic support and resistance levels, which can be more accurate than static support and resistance lines.
Limitations of the Ichimoku Kinko Hyo:
- Complexity: The Ichimoku Cloud can make a chart look busy due to the multiple lines it plots. This can be overwhelming for beginners or those who prefer a cleaner chart for analysis.
- Lagging Indicator: Despite its forward-looking nature, the Ichimoku Cloud is still based on historical data. While it projects averages into the future, there’s nothing inherently predictive in its formula.
- Cultural Differences: The standard settings of the Ichimoku Kinko Hyo are based on the Japanese trading week and may not be suitable for all markets.
- Cloud is Hopeless in Sideways Markets: While it can provide valuable insights in trending markets, the cloud’s effectiveness is pretty useless in sideways or range-bound markets.
Coding Ichimoku Kinko Hyo
Coding the Ichimoku Kinko Hyo in popular trading languages like Python and R allows traders to automate their Ichimoku strategy.
Code in Python
Here’s a simplified example of how you might code the Ichimoku Kinko Hyo in Python:
import pandas as pd
import numpy as np
# Define the Ichimoku Kinko Hyo
def ichimoku(df):
high_prices = df['High']
close_prices = df['Close']
low_prices = df['Low']
dates = df.index
# Tenkan-sen (Conversion Line)
nine_period_high = high_prices.rolling(window=9).max()
nine_period_low = low_prices.rolling(window=9).min()
df['tenkan_sen'] = (nine_period_high + nine_period_low) / 2
# Kijun-sen (Base Line)
twenty_six_period_high = high_prices.rolling(window=26).max()
twenty_six_period_low = low_prices.rolling(window=26).min()
df['kijun_sen'] = (twenty_six_period_high + twenty_six_period_low) / 2
# Senkou Span A (Leading Span A)
df['senkou_span_a'] = ((df['tenkan_sen'] + df['kijun_sen']) / 2).shift(26)
# Senkou Span B (Leading Span B)
fifty_two_period_high = high_prices.rolling(window=52).max()
fifty_two_period_low = low_prices.rolling(window=52).min()
df['senkou_span_b'] = ((fifty_two_period_high + fifty_two_period_low) / 2).shift(26)
# Chikou Span (Lagging Span)
df['chikou_span'] = close_prices.shift(-26)
return df
This code calculates each component of the Ichimoku Kinko Hyo and adds them as new columns to the DataFrame.
Code in R
In R it would be:
# Install and load the necessary packages
install.packages(c("quantmod", "TTR"))
library(quantmod)
library(TTR)
# Download historical data for desired ticker
getSymbols("PLTR", src = "yahoo", from = "2020-01-01", to = "2023-12-31")
data <- PLTR
# Calculate Tenkan Sen (Conversion Line)
high_9 <- runMax(Hi(data), n = 9)
low_9 <- runMin(Lo(data), n = 9)
data$tenkan_sen <- (high_9 + low_9) / 2
# Calculate Kijun Sen (Base Line)
high_26 <- runMax(Hi(data), n = 26)
low_26 <- runMin(Lo(data), n = 26)
data$kijun_sen <- (high_26 + low_26) / 2
# Calculate Senkou Span A (Leading Span A)
data$senkou_span_a <- (data$tenkan_sen + data$kijun_sen) / 2
data$senkou_span_a <- lag(data$senkou_span_a, 26)
# Calculate Senkou Span B (Leading Span B)
high_52 <- runMax(Hi(data), n = 52)
low_52 <- runMin(Lo(data), n = 52)
data$senkou_span_b <- (high_52 + low_52) / 2
data$senkou_span_b <- lag(data$senkou_span_b, 26)
# Calculate Chikou Span (Lagging Span)
data$chikou_span <- lag(Cl(data), -26)
The above script fetches historical data for a specific stock, calculates the Ichimoku Kinko Hyo components, and adds them as new columns to the data frame. The lag
function is used to shift the Senkou Span A, Senkou Span B, and Chikou Span lines as required by the Ichimoku Kinko Hyo system.
Complete Python Script to Plot Ichimoku for a Stock
We can make a full Python script that uses the pandas
, yfinance
, and
libraries to download historical data for the Palantir PLTR stock, and calculate the Ichimoku Kinko Hyo components and plot them on a line chart as follows:matplotlib
import pandas as pd
import yfinance as yf
import matplotlib.pyplot as plt
# Define the Ichimoku Kinko Hyo
def ichimoku(df):
high_prices = df['High']
close_prices = df['Close']
low_prices = df['Low']
# Tenkan-sen (Conversion Line)
nine_period_high = high_prices.rolling(window=9).max()
nine_period_low = low_prices.rolling(window=9).min()
df['tenkan_sen'] = (nine_period_high + nine_period_low) / 2
# Kijun-sen (Base Line)
twenty_six_period_high = high_prices.rolling(window=26).max()
twenty_six_period_low = low_prices.rolling(window=26).min()
df['kijun_sen'] = (twenty_six_period_high + twenty_six_period_low) / 2
# Senkou Span A (Leading Span A)
df['senkou_span_a'] = ((df['tenkan_sen'] + df['kijun_sen']) / 2).shift(26)
# Senkou Span B (Leading Span B)
fifty_two_period_high = high_prices.rolling(window=52).max()
fifty_two_period_low = low_prices.rolling(window=52).min()
df['senkou_span_b'] = ((fifty_two_period_high + fifty_two_period_low) / 2).shift(26)
# Chikou Span (Lagging Span)
df['chikou_span'] = close_prices.shift(-26)
return df
# Download historical data for PLTR
data = yf.download('PLTR', start='2020-01-01', end='2023-12-31')
# Calculate Ichimoku Kinko Hyo components
ichimoku_data = ichimoku(data)
# Plot the data
plt.figure(figsize=(12,8))
plt.plot(ichimoku_data.index, ichimoku_data['Close'], label='Close', color='black')
plt.plot(ichimoku_data.index, ichimoku_data['tenkan_sen'], label='Tenkan Sen', color='red')
plt.plot(ichimoku_data.index, ichimoku_data['kijun_sen'], label='Kijun Sen', color='blue')
plt.plot(ichimoku_data.index, ichimoku_data['senkou_span_a'], label='Senkou Span A', color='green')
plt.plot(ichimoku_data.index, ichimoku_data['senkou_span_b'], label='Senkou Span B', color='lightgreen')
plt.fill_between(ichimoku_data.index, ichimoku_data['senkou_span_a'], ichimoku_data['senkou_span_b'], where=ichimoku_data['senkou_span_a'] >= ichimoku_data['senkou_span_b'], color='lightgreen', alpha=0.5)
plt.fill_between(ichimoku_data.index, ichimoku_data['senkou_span_a'], ichimoku_data['senkou_span_b'], where=ichimoku_data['senkou_span_a'] < ichimoku_data['senkou_span_b'], color='lightcoral', alpha=0.5)
plt.plot(ichimoku_data.index, ichimoku_data['chikou_span'], label='Chikou Span', color='brown')
plt.legend(loc='upper left')
plt.title('PLTR Ichimoku Kinko Hyo Chart')
plt.xlabel('Date')
plt.ylabel('Price')
plt.grid(True)
plt.show()
This script can be run in VSCode which you can get from Microsoft for free or any other Python environment.
Please note that if you need to install the yfinance
library or the others to run this script you can install it using pip, e.g.:
pip install pandas yfinance matplotlib
Some of my other articles have more detail on putting the code together and running it in VSCode if you get stuck, but it’s the same principle. You can check out the Commodity Channel Index (CCI) post for example.
The Cloud Chart Generated by the Python Script
On the chart this produces below, green and pink shading represents the “cloud” or “Kumo” in the Ichimoku Kinko Hyo. The cloud is the area between the Senkou Span A and Senkou Span B lines. When Senkou Span A is above Senkou Span B, the cloud is shaded green, conversely, when Senkou Span B is above Senkou Span A, the cloud is shaded pink (the colour changes have no real strategic importance):
Checking the Cloud Chart is Correct
You may wish to check your code is outputting the correct patterns for your own sanity, so what I did was compare it to the Yahoo finance chart on their website for a particular date range with the same 9,26,52,26 default settings (you could change all the line colours to be the same for the corresponding ones if easier I but didn’t here). I might have been a day off in the crop comparison below compared to the end of the chart lines in the one above, but try it yourself and you’ll find they match with Yahoo’s:
Practical Tips for Using Ichimoku Kinko Hyo in Trading
Utilising an Ichimoku cloud strategy can be a great way to enhance your trading, but like any tool, it’s important to know how to use it effectively. Here are some practical tips for using the Ichimoku Kinko Hyo in your trading:
- Understand the Components: Each line of the Ichimoku Kinko Hyo provides different information. Understanding what each line represents can help you make more informed trading decisions, we’ve broken this down earlier in this article.
- Use in Conjunction with Other Indicators: While the Ichimoku Kinko Hyo is comprehensive, it can be beneficial to use it in conjunction with other technical indicators. For example, using it with the RSI can help confirm momentum in a certain direction.
- Consider the Bigger Picture: Always consider the bigger trend when using the Ichimoku Kinko Hyo. For example, during a strong downtrend, the price may temporarily push into the cloud or slightly above it before falling again. Focusing solely on the Ichimoku Cloud during these times might cause you to miss the larger downtrend.
- Watch for Crossovers: Crossovers, such as when the Tenkan Sen (Conversion Line) crosses above the Kijun Sen (Base Line), can be powerful trading signals. These crossovers can be especially significant when they occur at or near the cloud. The colour change of the cloud and crossover of the cloud Senkou Span A and Senkou Span B lines are not important trading signals.
- Respect the Cloud: The Ichimoku Cloud can act as a dynamic area of support and resistance. When the price is above the cloud, it can act as support, and when the price is below the cloud, it can act as resistance but the actual distance of current price from the cloud is not important. The cloud can generally be ignored during sideway markets though and the colour of the cloud is not particularly insightful for trading signals compared to its thickness and position.
Key Takeaways
- The Ichimoku Kinko Hyo was developed by Goichi Hosoda in the early 1940s to provide a comprehensive view of the market trend, its direction, and support and resistance levels.
- It consists of five main components: Tenkan Sen (Conversion Line), Kijun Sen (Base Line), Senkou Span A (Leading Span A), Senkou Span B (Leading Span B), and Chikou Span (Lagging Span).
- The area between Senkou Span A and Senkou Span B, known as the “cloud” or “Kumo”, provides a graphical representation of areas of support and resistance.
- It can be coded in popular trading languages like Python and R for automation of trading strategies and we have provided you with the code to do that in this article.
- It provides buy and sell signals, with a buy signal occurring when the Tenkan Sen crosses above the Kijun Sen and the price is above the cloud, and a sell signal occurring when the Tenkan Sen crosses below the Kijun Sen and the price is below the cloud.
- The Ichimoku Kinko Hyo has its strengths and weaknesses. It provides a wealth of information at a glance and is versatile, but it can make a chart look confusing with its many components and is still based on lagging historical data despite projecting forward.
- It is most effective in trending markets and less effective in sideways or range-bound markets.
- Consider using it in conjunction with other technical indicators and strategies for maximum trading success.
Further Reading
Elliott, N. (2018). Ichimoku Charts: An Introduction to Ichimoku Kinko Clouds. (2nd Ed.) Harriman Trading
PĂ©loille, K. (2017). Trading with Ichimoku: A practical guide to low-risk Ichimoku strategies (1st ed.). Harriman House
Leave a Reply