Ichimoku Cloud Pine Script — Full Custom Indicator
Ichimoku Kinko Hyo (“one-glance equilibrium chart”) is a Japanese indicator system that gives you trend, momentum, support/resistance, and signals all in one view. TradingView has a built-in version, but custom Pine Script gives you full control over colours, alerts, and parameters. Here’s the complete code with all 5 components.
🎯 The 5 Ichimoku Components
1. Tenkan-sen (Conversion Line) — 9-period midpoint
2. Kijun-sen (Base Line) — 26-period midpoint
3. Senkou Span A (Leading Span A) — projected forward
4. Senkou Span B (Leading Span B) — slower projection
5. Chikou Span (Lagging Span) — close shifted back
The cloud (Kumo) between Senkou A and B = current trend strength.
Complete Pine Script v5 Code
//@version=5
indicator("Ichimoku Cloud — IA Trader Pro", overlay=true)
// === INPUTS ===
tenkanLen = input.int(9, "Tenkan-sen Period")
kijunLen = input.int(26, "Kijun-sen Period")
senkouLen = input.int(52, "Senkou Span B Period")
displace = input.int(26, "Cloud Displacement")
// === CALCULATIONS ===
midpoint(len) => math.avg(ta.highest(high, len), ta.lowest(low, len))
tenkan = midpoint(tenkanLen)
kijun = midpoint(kijunLen)
senkouA = math.avg(tenkan, kijun)
senkouB = midpoint(senkouLen)
chikou = close
// === PLOTS ===
p_tenkan = plot(tenkan, "Tenkan", color=#448AFF, linewidth=2)
p_kijun = plot(kijun, "Kijun", color=#FF5252, linewidth=2)
p_chikou = plot(chikou, "Chikou", color=#9C27B0, offset=-displace, linewidth=1)
// Cloud (displaced forward)
p_a = plot(senkouA, "Senkou A", color=#00E676, offset=displace, linewidth=1)
p_b = plot(senkouB, "Senkou B", color=#FF5252, offset=displace, linewidth=1)
// Fill cloud — bullish if A > B
fill(p_a, p_b, color=senkouA > senkouB ? color.new(#00E676, 80) :
color.new(#FF5252, 80))
// === SIGNAL CONDITIONS ===
bullCloud = senkouA > senkouB
bearCloud = senkouA < senkouB
tkCross_bull = ta.crossover(tenkan, kijun)
tkCross_bear = ta.crossunder(tenkan, kijun)
aboveCloud = close > senkouA and close > senkouB
belowCloud = close < senkouA and close < senkouB
// Strong BUY: TK bull cross + price above cloud + bull cloud
strongBuy = tkCross_bull and aboveCloud and bullCloud
strongSell = tkCross_bear and belowCloud and bearCloud
// === MARKERS ===
plotshape(strongBuy, "STRONG BUY", location.belowbar,
color=#00E676, style=shape.triangleup, size=size.small)
plotshape(strongSell, "STRONG SELL", location.abovebar,
color=#FF5252, style=shape.triangledown, size=size.small)
// === STATUS DASHBOARD ===
var table dash = table.new(position.top_right, 2, 4,
bgcolor=color.new(color.black, 20),
border_width=1, border_color=color.gray)
if barstate.islast
cloudTxt = bullCloud ? "BULL" : "BEAR"
cloudCol = bullCloud ? #00E676 : #FF5252
priceTxt = aboveCloud ? "ABOVE" : belowCloud ? "BELOW" : "INSIDE"
priceCol = aboveCloud ? #00E676 : belowCloud ? #FF5252 : #FFC107
tkTxt = tenkan > kijun ? "BULL" : "BEAR"
tkCol = tenkan > kijun ? #00E676 : #FF5252
score = (bullCloud ? 1 : -1) + (aboveCloud ? 1 : belowCloud ? -1 : 0) +
(tenkan > kijun ? 1 : -1)
table.cell(dash, 0, 0, "Cloud", text_color=color.white, text_size=size.tiny)
table.cell(dash, 1, 0, cloudTxt, text_color=cloudCol, text_size=size.tiny)
table.cell(dash, 0, 1, "Price", text_color=color.white, text_size=size.tiny)
table.cell(dash, 1, 1, priceTxt, text_color=priceCol, text_size=size.tiny)
table.cell(dash, 0, 2, "TK Cross", text_color=color.white, text_size=size.tiny)
table.cell(dash, 1, 2, tkTxt, text_color=tkCol, text_size=size.tiny)
table.cell(dash, 0, 3, "Score", text_color=color.white, text_size=size.tiny)
scoreCol = score >= 2 ? #00E676 : score <= -2 ? #FF5252 : #FFC107
table.cell(dash, 1, 3, str.tostring(score, "+0;-0"),
text_color=scoreCol, text_size=size.tiny)
// === ALERTS ===
alertcondition(strongBuy, "Ichimoku STRONG BUY",
"All 3 Ichimoku conditions bullish on {{ticker}}")
alertcondition(strongSell, "Ichimoku STRONG SELL",
"All 3 Ichimoku conditions bearish on {{ticker}}")Interpretation Guide
- Price above bullish cloud (green) + TK cross up = STRONG BUY
- Price below bearish cloud (red) + TK cross down = STRONG SELL
- Price inside cloud = consolidation, don’t trade
- Cloud thick = strong trend
- Cloud thin = weak trend, possible reversal
- Chikou span above price = bullish confirmation
Best Timeframes
Ichimoku was designed for daily charts. Adjust:
- Daily (recommended): default settings (9, 26, 52, 26)
- 4H: use same settings but expect more noise
- 1H: try (7, 22, 44, 22) — slightly faster
- M15 and below: Ichimoku struggles, use other indicators
SA Asset Performance
📊 Where Ichimoku Works Best
• USD/ZAR daily: excellent — captures multi-week trends well
• JSE Top 40 (J200) daily: good for trend-following
• EUR/USD H4: moderate, expect false signals
• V75 (synthetic): poor — V75 doesn’t trend strongly enough for Ichimoku
• BTC/USD daily: good during trending periods
For V75 and synthetic indices, RSI mean reversion works better.
Common Mistakes
- Trading inside the cloud: wait for breakout
- Ignoring cloud thickness: thin cloud = weak conviction
- Using on V75: wrong tool for synthetic mean-reversion
- Combining with too many indicators: Ichimoku is already a multi-component system
- Wrong timeframe: Ichimoku optimised for daily, not M5
Convert to Strategy for Backtesting
Prompt AI: “Convert this Ichimoku indicator to Pine v5 strategy with 2% sizing, 1.5% SL, 3% TP, commission 0.05%, initial $1000. Entry on strongBuy/strongSell. Use ATR-based dynamic stops instead of fixed percentage.”
🚀 Test Ichimoku on Deriv MT5 (FSCA-licensed, free demo):
Open Free Demo Account →