The Ichimoku Trend Strategy uses the Ichimoku Kinko Hyo system — the Conversion Line (Tenkan-sen), Base Line (Kijun-sen), and the Cloud (Kumo) — to describe trend direction and structure on a chart. Traders typically use it as a framework for reading whether price is in an up-context or down-context and where momentum and support/resistance may sit. It is an educational and analytical tool only; it does not predict future prices, and trading carries the risk of loss.
Ichimoku ("one glance equilibrium chart") layers several averages of price extremes so you can read trend, momentum, and support/resistance at a glance. The Conversion Line (Tenkan-sen) is the midpoint of the highest high and lowest low over a short window (default 9). The Base Line (Kijun-sen) is the same midpoint over a longer window (default 26). The Cloud is bounded by two "Leading Span" lines: Leading Span A is the average of the Conversion and Base lines, and Leading Span B is the midpoint over a long window (default 52). Both Leading Spans are plotted shifted forward (displaced) by 26 bars, which is what creates the projected Cloud ahead of price. A separate Lagging Span (Chikou) plots the close shifted backward.
In plain terms: when price trades above the Cloud and the Cloud is "green" (Span A above Span B), the chart is in an up-context; below a "red" Cloud is a down-context; inside the Cloud is treated as undefined or transitional. The Conversion/Base relationship acts like a faster momentum read inside that bigger context. Some traders combine these — for example, only looking for long setups when price is above the Cloud and the Conversion is above the Base — to filter for trend alignment rather than reacting to every crossover. Nothing here forecasts price; it is a structured way to describe what price has already done.
//@version=6
// Ichimoku Trend Strategy — educational example, not financial advice.
// Illustrative only; past performance does not indicate future results.
indicator("Ichimoku Trend Strategy (Educational)", overlay = true)
// --- Inputs ---
convLen = input.int(9, "Conversion (Tenkan) length", minval = 1)
baseLen = input.int(26, "Base (Kijun) length", minval = 1)
spanBLen = input.int(52, "Leading Span B length", minval = 1)
disp = input.int(26, "Cloud displacement", minval = 1)
// --- Donchian midpoint helper ---
midpoint(len) =>
math.avg(ta.highest(high, len), ta.lowest(low, len))
// --- Ichimoku lines ---
conversion = midpoint(convLen)
base = midpoint(baseLen)
leadSpanA = math.avg(conversion, base) // Senkou Span A (computed at current bar)
leadSpanB = midpoint(spanBLen) // Senkou Span B (computed at current bar)
// --- Plots ---
// Cloud is DISPLAYED forward via offset; this is visual only and does not feed signals.
plot(conversion, "Conversion (Tenkan)", color = color.new(color.blue, 0))
plot(base, "Base (Kijun)", color = color.new(color.red, 0))
pA = plot(leadSpanA, "Leading Span A", color = color.new(color.green, 60), offset = disp)
pB = plot(leadSpanB, "Leading Span B", color = color.new(color.red, 60), offset = disp)
fill(pA, pB, color = leadSpanA >= leadSpanB ? color.new(color.green, 85) : color.new(color.red, 85), title = "Cloud")
// --- Signal logic (no look-ahead): compare current close to the cloud as drawn under this bar ---
// The cloud segment under the current bar was computed `disp` bars ago, so reference the past spans.
spanAnow = leadSpanA[disp]
spanBnow = leadSpanB[disp]
cloudTop = math.max(spanAnow, spanBnow)
cloudBottom = math.min(spanAnow, spanBnow)
bullCloud = spanAnow > spanBnow
bearCloud = spanAnow < spanBnow
aboveCloud = close > cloudTop
belowCloud = close < cloudBottom
longContext = aboveCloud and bullCloud
shortContext = belowCloud and bearCloud
longTrigger = ta.crossover(conversion, base) and longContext
shortTrigger = ta.crossunder(conversion, base) and shortContext
// Evaluate on confirmed (closed) bars only.
longConfirmed = longTrigger and barstate.isconfirmed
shortConfirmed = shortTrigger and barstate.isconfirmed
plotshape(longConfirmed, title = "Long context", style = shape.triangleup, location = location.belowbar, color = color.new(color.green, 0), size = size.tiny)
plotshape(shortConfirmed, title = "Short context", style = shape.triangledown, location = location.abovebar, color = color.new(color.red, 0), size = size.tiny)
alertcondition(longConfirmed, title = "Long context", message = "Ichimoku: long-context conditions met on bar close (educational)")
alertcondition(shortConfirmed, title = "Short context", message = "Ichimoku: short-context conditions met on bar close (educational)")No. The Cloud is plotted shifted forward, so the section drawn ahead of the current candle is built entirely from past price data — it is a projection of old values, not a forecast. Ichimoku describes the trend, momentum, and support/resistance structure that price has already created. Nothing on the chart is predictive, and trading always carries the risk of loss.
They are the lookback lengths for the Conversion Line (9), the Base Line and the displacement (26), and Leading Span B (52). They come from daily-chart conventions and are widely used, but they are not 'correct' or optimal for every market or timeframe. If you change them, test the change out-of-sample rather than tuning until past data looks good — over-fit settings often fail on new data.
ForexCodes focuses on validation. When you bring an Ichimoku idea into the Strategy Validator, it checks the generated Pine v6 for issues like look-ahead bias from the Cloud displacement, intrabar repainting on the Conversion/Base cross, and mismatches between what you described and what the code actually does — so the script behaves the way you intended. It is an educational and software tool; it does not promise outcomes.
Educational & software only — not financial advice, not a recommendation to trade. Backtests are illustrative; past performance does not predict future results. Trading involves substantial risk of loss.