Trend indicator
Ichimoku Cloud Calculator
Enter the high and low for each of the three standard lookback windows, plus the current close, to compute every Ichimoku Cloud component: Tenkan-sen, Kijun-sen, both Senkou spans, the cloud they form, and the Chikou span.
For each window, enter the highest high and lowest low over that many periods. The default lengths are 9 for Tenkan-sen, 26 for Kijun-sen, and 52 for Senkou Span B, the values Goichi Hosoda originally set them to.
| Component | Value |
|---|---|
| Tenkan-sen (conversion line) | 114.00 |
| Kijun-sen (base line) | 114.00 |
| Senkou Span A (leading span A) | 114.00 |
| Senkou Span B (leading span B) | 114.70 |
| Cloud top | 114.70 |
| Cloud bottom | 114.00 |
| Chikou Span (lagging span) | 114.50 |
What the Ichimoku Cloud measures
The Ichimoku Kinko Hyo, usually shortened to the Ichimoku Cloud, is a Japanese charting system developed by Goichi Hosoda and published in the late 1960s. It condenses trend direction, momentum, and support and resistance into a single set of lines and a shaded region, the cloud, all derived from nothing more than rolling highs and lows.
Tenkan-sen and Kijun-sen are both the midpoint of a high/low range, over 9 and 26 periods respectively, which makes them close relatives of a simple moving average but more responsive to recent extremes than to every close in between. Senkou Span A is the midpoint of Tenkan-sen and Kijun-sen, and Senkou Span B is the midpoint of the 52-period range. On a real chart, both spans are plotted 26 periods ahead of the current bar, and the shaded area between them forms the cloud. The Chikou Span is simply the current close, plotted 26 periods in the past, which lets you compare today's price against where price was reacting a full cycle ago.
Reading the cloud
Price trading above the cloud is generally read as a bullish structural bias, below the cloud as bearish, and inside the cloud as a period of consolidation or transition where the trend is not clearly established. The cloud's thickness at any point reflects how far apart Senkou Span A and Senkou Span B are, which traders sometimes read as a proxy for how much support or resistance that price region is likely to offer.
Because Senkou Span A and B are both plotted displaced into the future, the cloud ahead of current price is already fully determined by past data. That forward-looking shape is the distinctive feature of the system, and it is also why the cloud can appear to define support and resistance zones for bars that have not happened yet. Whether and how to act on any of this is a judgment call that belongs entirely to you.
What are TradingView and Pine Script?
TradingView is one of the most widely used charting and market-analysis platforms, where traders and analysts study price movement across stocks, crypto, forex, and futures on interactive charts. Pine Script is TradingView's own lightweight programming language, created so anyone can build custom tools that run directly on those charts.
People use Pine Script to build four main kinds of tools. Indicators calculate and plot values on the chart, exactly like the calculation above, but recomputed automatically on every bar. Strategies add explicit entry and exit rules and can be backtested against historical data in TradingView's Strategy Tester to see how they would have behaved. Screeners scan many symbols at once for conditions you define. Alerts notify you the moment a condition you specified occurs, so you do not have to watch the screen.
The value is precision and automation. Instead of eyeballing a chart, you describe exactly what you want measured, visualized, or notified about, and TradingView runs it consistently across any market and timeframe. That is why traders, analysts, and developers write Pine Script: it turns a manual charting idea into a repeatable tool. These tools are for tracking, visualizing, and testing market ideas; they do not tell you what to trade, and that decision always remains yours.
Writing that code by hand means learning Pine Script's syntax, its type system, and the exact names of hundreds of built-in functions. It is a real programming language, and small mistakes stop a script from compiling in the Pine Editor.
Turn this into Pine Script
This calculator computes each component from a single snapshot of highs and lows. On a TradingView chart, every line recalculates on every bar from a rolling window, and the two Senkou spans need to be plotted with a positive offset so they project into the future while the Chikou Span needs a negative one so it shifts into the past. Getting the direction of that offset backward is the most common mistake when coding Ichimoku by hand, and it silently produces a chart that looks plausible but has the cloud and the lagging span both facing the wrong way. If you are also building pivot-based structure indicators alongside a cloud, the guide on ta.pivothigh and ta.pivotlow covers a similar directional offset mistake in a different function.
//@version=6
indicator("Ichimoku Cloud", overlay=true)
conversionLen = input.int(9, "Tenkan-sen length")
baseLen = input.int(26, "Kijun-sen length")
spanBLen = input.int(52, "Senkou Span B length")
displacement = input.int(26, "Cloud displacement")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
tenkanSen = donchian(conversionLen)
kijunSen = donchian(baseLen)
senkouSpanA = math.avg(tenkanSen, kijunSen)
senkouSpanB = donchian(spanBLen)
chikouSpan = close
plot(tenkanSen, "Tenkan-sen", color=color.blue)
plot(kijunSen, "Kijun-sen", color=color.red)
plot(chikouSpan, "Chikou Span", offset=-displacement, color=color.green)
// Senkou spans are plotted 'displacement' bars into the future, and the
// space between them is filled to form the cloud (kumo).
spanA = plot(senkouSpanA, "Senkou Span A", offset=displacement, color=color.new(color.green, 60))
spanB = plot(senkouSpanB, "Senkou Span B", offset=displacement, color=color.new(color.red, 60))
fill(spanA, spanB, color=senkouSpanA > senkouSpanB ? color.new(color.green, 90) : color.new(color.red, 90))PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.