Ichimoku Cloud
Ichimoku Cloud (Ichimoku Kinko Hyo)
- Category: Trend — Overlay Indicator
- Default Parameters: tenkanPeriod=9, kijunPeriod=26, senkouBPeriod=52, displacement=26
- Output: Five lines + cloud (Kumo) region
- Applicable Markets: Stocks, Futures, Forex, Cryptocurrencies
I. What is the Ichimoku Cloud
The Ichimoku Cloud (Ichimoku Kinko Hyo) is a comprehensive technical analysis system developed by Japanese journalist Goichi Hosoda (pen name “Ichimoku Sanjin”) starting in the 1930s. He spent nearly 30 years developing and verifying it with the help of university students performing manual calculations, and officially published it in 1969.
“Ichimoku Kinko Hyo” translates to “equilibrium chart at a glance” in Japanese. Its core philosophy is to present trend direction, support/resistance, and momentum strength simultaneously on a single chart, allowing traders to make decisions without switching between multiple indicators.
Five Core Lines
| Name | Japanese | Meaning |
|---|---|---|
| Conversion Line | Tenkan-sen | Short-term equilibrium price (9 periods) |
| Base Line | Kijun-sen | Medium-term equilibrium price (26 periods) |
| Leading Span A | Senkou Span A | Upper cloud boundary (average of Tenkan and Kijun, shifted forward 26 periods) |
| Leading Span B | Senkou Span B | Lower cloud boundary (52-period equilibrium price, shifted forward 26 periods) |
| Lagging Span | Chikou Span | Current closing price shifted backward 26 periods |
The default parameters 9-26-52 originate from the Japanese stock market’s early 6-day trading week: 9 represents one and a half weeks, 26 represents one month, and 52 represents two months. Although modern markets have shifted to a 5-day trading week, this parameter set remains widely used across global markets.
II. Mathematical Principles and Calculation
Core Formulas
Conversion Line (Tenkan-sen):
Where is the highest high over the past 9 periods, and is the lowest low over the past 9 periods.
Base Line (Kijun-sen):
Leading Span A (Senkou Span A):
This value is plotted 26 periods ahead of the current time.
Leading Span B (Senkou Span B):
Also plotted 26 periods ahead of the current time.
Lagging Span (Chikou Span):
The current closing price is plotted 26 periods behind.
Cloud (Kumo):
When , it forms a bullish cloud (typically green); otherwise, it forms a bearish cloud (typically red).
Calculation Steps
- For each time point, calculate the midpoint for the 9-period, 26-period, and 52-period windows
- Average Tenkan and Kijun to obtain Senkou A, then shift it forward by 26 periods
- Calculate the 52-period midpoint price for Senkou B, then shift it forward by 26 periods
- Shift the closing price backward by 26 periods to form Chikou
III. Python Implementation
import numpy as np
import pandas as pd
def ichimoku_cloud(df: pd.DataFrame,
tenkan_period: int = 9,
kijun_period: int = 26,
senkou_b_period: int = 52,
displacement: int = 26) -> pd.DataFrame:
"""
Calculate the five lines and cloud of the Ichimoku Cloud.
Parameters
----------
df : DataFrame, must contain 'high', 'low', 'close' columns
tenkan_period : Conversion line period, default 9
kijun_period : Base line period, default 26
senkou_b_period : Leading Span B period, default 52
displacement : Forward/backward shift periods, default 26
Returns
----------
DataFrame with tenkan, kijun, senkou_a, senkou_b, chikou columns
"""
high = df['high']
low = df['low']
close = df['close']
# ---------- Conversion Line ----------
tenkan = (high.rolling(window=tenkan_period).max()
+ low.rolling(window=tenkan_period).min()) / 2
# ---------- Base Line ----------
kijun = (high.rolling(window=kijun_period).max()
+ low.rolling(window=kijun_period).min()) / 2
# ---------- Leading Span A (shifted forward by displacement periods) ----------
senkou_a = ((tenkan + kijun) / 2).shift(displacement)
# ---------- Leading Span B (shifted forward by displacement periods) ----------
senkou_b = ((high.rolling(window=senkou_b_period).max()
+ low.rolling(window=senkou_b_period).min()) / 2).shift(displacement)
# ---------- Lagging Span (shifted backward by displacement periods) ----------
chikou = close.shift(-displacement)
result = pd.DataFrame({
'tenkan': tenkan,
'kijun': kijun,
'senkou_a': senkou_a,
'senkou_b': senkou_b,
'chikou': chikou
}, index=df.index)
return result
# ========== Usage Example ==========
if __name__ == "__main__":
np.random.seed(42)
n = 120
dates = pd.date_range('2024-01-01', periods=n, freq='B')
# Simulate OHLCV data
price = 100 + np.cumsum(np.random.randn(n) * 0.8)
df = pd.DataFrame({
'open': price + np.random.uniform(-0.5, 0.5, n),
'high': price + np.abs(np.random.randn(n)) * 1.2,
'low': price - np.abs(np.random.randn(n)) * 1.2,
'close': price + np.random.uniform(-0.3, 0.3, n),
'volume': np.random.randint(1000, 5000, n)
}, index=dates)
ichi = ichimoku_cloud(df)
merged = df.join(ichi)
print(merged[['close', 'tenkan', 'kijun', 'senkou_a', 'senkou_b', 'chikou']].tail(15))
# Determine cloud color
merged['cloud_bullish'] = merged['senkou_a'] > merged['senkou_b']
print("\nCloud status for the last 5 periods:")
print(merged[['senkou_a', 'senkou_b', 'cloud_bullish']].dropna().tail(5))
In backtesting, Senkou A/B using shift(displacement) will produce NaN values at the end of the series. If you need to evaluate “future cloud” signals, you can skip the shift and compare the raw values directly.
IV. Problems the Indicator Solves
1. Trend Identification
- Price above the cloud —> Uptrend
- Price below the cloud —> Downtrend
- Price inside the cloud —> Consolidation / Transition phase
2. Support and Resistance
The cloud itself acts as a dynamic support/resistance zone. A thicker cloud implies stronger support/resistance; a thinner cloud makes it easier for price to break through.
3. Crossover Signals
| Signal Type | Condition | Meaning |
|---|---|---|
| TK Bullish Cross | Tenkan crosses above Kijun | Short-term momentum turns bullish |
| TK Bearish Cross | Tenkan crosses below Kijun | Short-term momentum turns bearish |
| Strong Bullish Cross | TK bullish cross above the cloud | High-confidence buy signal |
| Weak Bullish Cross | TK bullish cross below the cloud | Low-confidence signal, proceed with caution |
4. Lagging Span Confirmation
When Chikou (Lagging Span) is above the price from 26 periods ago, it confirms a bullish trend; when it is below, it confirms a bearish trend.
5. Cloud Twist
A crossover of Senkou A and Senkou B (cloud color change) signals a potential trend reversal ahead.
Ichimoku Cloud signals are most reliable when all five elements align: TK cross direction, price-to-cloud relationship, Lagging Span confirmation, cloud color, and cloud thickness all point in the same direction.
V. Advantages, Disadvantages, and Use Cases
Advantages
- Comprehensive information: A single chart displays trend, support/resistance, and momentum, reducing “indicator clutter”
- Forward-looking: The cloud is projected 26 periods ahead, providing potential future support/resistance levels
- Adaptive: Based on period midpoints rather than averages, more stable than moving averages during sharp volatility
- Excellent in trending markets: Signals are clear with few false signals in strong trends
Disadvantages
- Poor in ranging markets: All five lines intertwine during consolidation, generating confusing signals
- Visually complex: Beginners need time to learn reading five lines and a cloud
- Lagging nature: Based on historical extreme values, slow to react to sudden reversals
- Fixed parameters: The default 9-26-52 may not be suitable for short timeframes (e.g., 1-minute charts)
Use Cases
| Scenario | Suitability | Notes |
|---|---|---|
| Daily/Weekly trend trading | High | The classic application timeframe |
| Forex 4H charts | High | Continuous forex market fits the parameters well |
| Crypto daily charts | Medium-High | 24/7 market may require parameter adjustments |
| 1-minute scalping | Low | Too much noise, unstable signals |
| Narrow range consolidation | Low | Lines intertwine, no clear direction |
Comparison with Similar Indicators
| Dimension | Ichimoku Cloud | Bollinger Bands | Moving Average Set |
|---|---|---|---|
| Information Dimensions | Trend + S/R + Momentum | Volatility + Overbought/Oversold | Trend direction |
| Forward-looking | Yes (cloud projection) | No | No |
| Number of Parameters | 4 | 2 | Varies by line count |
| Learning Curve | Steep | Gentle | Gentle |
- Use daily or higher timeframes for optimal results
- First observe cloud color and thickness for the overall trend, then look for TK crossovers for entry points
- Combine with volume indicators (e.g., OBV) for signal confirmation
- Follow signals in trending markets; reduce position size or pause trading during consolidation