VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
TRADING RESEARCH CLUB / Indicators and signals

Ichimoku cloud: the five lines, signals and how to backtest them

The Ichimoku cloud is five lines built from range midpoints, two of them shifted in time. To backtest it on futures, write each signal as an exact rule, read the shifted lines only with data known at the time, include costs and test settings near 9, 26, 52.

By · Published · updated · Editorial policy

Contents
  1. What is the Ichimoku cloud, and can you backtest it?
  2. How are the five Ichimoku lines calculated?
  3. Which Ichimoku signals can you turn into test rules?
  4. How do you avoid look-ahead error with the shifted lines?
  5. Should you keep the 9, 26, 52 settings?
  6. Where does the Ichimoku cloud struggle?
  7. Frequently asked questions
  8. References

What is the Ichimoku cloud, and can you backtest it?

The Ichimoku cloud is a chart indicator built from five lines: Tenkan, Kijun, Senkou Span A, Senkou Span B and Chikou. Traders take signals from price breaking out of the cloud, Tenkan–Kijun crosses and cloud color. To test them on futures, write each signal as an exact rule, align the shifted lines correctly, include costs and test nearby settings.

The Ichimoku indicator (full name Ichimoku Kinko Hyo) is a trend-following system that shows trend direction, support and resistance and momentum in one display. It was developed by the Japanese journalist Goichi Hosoda and published in 1969. Most of its lines answer one simple question: where is the middle of the recent price range? Picture a river. If you mark the highest and lowest water level of the last few weeks, the halfway mark tells you whether today's level is high or low for the season. Ichimoku draws that halfway mark for three different lengths of time.

How are the five Ichimoku lines calculated?

Three Ichimoku lines are range midpoints, one is an average of two midpoints, and one is simply the closing price moved back in time. The basic building block is this:

Midpoint = (highest high of the last N bars + lowest low of the last N bars) ÷ 2

Here N is the number of bars you look back, the "highest high" is the highest price reached in those bars, and the "lowest low" is the lowest price reached in those bars. With the default settings, the five lines are:

LineAlso calledCalculation in wordsWhere it is drawn
Tenkan-senConversion lineMidpoint of the last 9 barsOn the current bar
Kijun-senBase lineMidpoint of the last 26 barsOn the current bar
Senkou Span ALeading span AAverage of Tenkan and Kijun26 bars ahead
Senkou Span BLeading span BMidpoint of the last 52 bars26 bars ahead
Chikou SpanLagging spanThe current close26 bars back

The cloud (in Japanese, the kumo) is the shaded area between Senkou Span A and Senkou Span B. Charts usually color it green when Span A is above Span B and red when Span B is above Span A. A thick cloud means the two spans are far apart. A thin cloud means they are close together.

Anatomy of an Ichimoku chart: Tenkan and Kijun end at today's bar, the cloud between Span A and Span B extends 26 bars ahead of today, and the Chikou line ends 26 bars before today Two parts are moved in time Cloud drawn ahead, Chikou drawn back 26 bars 26 bars Chikou Tenkan Kijun Span A Span B Today Two parts sit 26 bars off today. So: check which bar you read.
The anatomy of an Ichimoku chart: Tenkan and Kijun sit on the current bar, the cloud is drawn 26 bars ahead, and Chikou is drawn 26 bars back.

Which Ichimoku signals can you turn into test rules?

An Ichimoku signal becomes testable only when you write it as a rule that gives the same answer every time, with no judgment. "Price looks strong above the cloud" cannot be tested. "The close crosses above the higher of Span A and Span B" can. The common signals, written as rules:

SignalLong ruleShort ruleTypical role
Cloud breakoutClose crosses above the cloud top (the higher of Span A and Span B at that bar)Close crosses below the cloud bottom (the lower of the two)Entry
TK crossTenkan crosses above KijunTenkan crosses below KijunEntry
Cloud colorThe newest cloud, drawn ahead, is greenThe newest cloud is redFilter
Chikou confirmationClose is above the close 26 bars agoClose is below the close 26 bars agoFilter
Kijun exitExit long when close falls below KijunExit short when close rises above KijunExit

A TK cross is the moment the Tenkan line crosses the Kijun line. Traditional Ichimoku practice rates a bullish TK cross as strong when it happens above the cloud, neutral inside the cloud and weak below it, and the reverse for bearish crosses. That rating is itself a rule you can test: run the TK cross alone, then run it only when price is above the cloud, and compare.

Build an Ichimoku strategy one layer at a time:

  1. Test one entry signal alone, with a simple fixed exit, to see whether it has any edge after costs.
  2. Add one filter (for example cloud color) and check whether it removes more losing trades than winning ones.
  3. Replace the simple exit with an Ichimoku exit such as the Kijun exit, and compare.
  4. Stop adding conditions when a new one changes little. Each condition adds settings that can be fitted to noise.

This layered approach matches how AlphaPrime (Valynox) handles strategy generation: research ideas become testable rules with defined entry and exit conditions, parameter ranges and search constraints.

How do you avoid look-ahead error with the shifted lines?

You avoid look-ahead error by making every rule at bar t use only values that were calculated from bars up to and including bar t. Look-ahead error is a backtest mistake where a rule uses information that did not yet exist when the trade was taken. Ichimoku invites this mistake because the chart places values at bars where they were not calculated.

Which Ichimoku values are known at bar t: spans calculated at t minus 26 form the cloud under today's price, spans calculated at t form the cloud drawn at t plus 26, today's close is drawn as Chikou at t minus 26, and the Chikou value drawn at t is the close of bar t plus 26, so reading it is unsafe Read only what is known at t Dot: calculated · Arrow: drawn t−26 t t+26 Cloud now Cloud ahead Chikou Chikou at t Chikou at t is a future close. So: compare close with t−26.
Which Ichimoku values are known at bar t. The Chikou value plotted at today's bar comes from 26 bars in the future, so a rule must never read it.
  1. The cloud under today's price uses Span A and Span B calculated 26 bars ago. When your rule asks "is price above the cloud?", compare today's close with those older values, because that is the cloud you see under today's bar.
  2. The cloud drawn ahead uses Span A and Span B calculated today. These values are known now, so a cloud-color filter based on them is safe.
  3. Chikou must never be read at its plotted position. The Chikou value drawn at today's bar is the close of a bar 26 bars in the future. Write the rule as "today's close compared with the close 26 bars ago" instead.
  4. Unfinished bars change Tenkan and Kijun until the bar closes, because the current bar's high and low are part of the range. Decide at the bar close and enter on the next bar.
  5. Warm-up bars are needed before the first valid signal. The cloud under price needs 52 bars for Span B plus the 26-bar shift, so ignore signals in roughly the first 78 bars of data.

Platforms can differ by one bar in how they count the 26-bar shift. If you compare your rule with a chart on a trading platform, check which convention that platform uses. AlphaPrime's backtesting covers next-bar execution, fees and slippage and trading sessions, which deals with point 4 and with the cost side of the test.

Should you keep the 9, 26, 52 settings?

Treat 9, 26, 52 as a starting point, not as correct values, and judge any setting by how its neighbours perform. The usual explanation for the defaults is the six-day Japanese trading week of the time: 9 days is about a week and a half, 26 days about a month, and 52 days about two months. On intraday futures bars that link to the calendar disappears. On 15-minute bars, 26 bars is six and a half hours of trading, and 52 bars is thirteen hours.

Session choice changes this too. If your bars include the night session, a 52-bar window covers different hours than on day-session-only bars, and the cloud will look different. Decide on the session before you compare settings. The same rule on different bars gives different Ichimoku clouds, so test each bar type separately.

To test settings for stability, run a small grid around the defaults and keep the ratio between the three lengths roughly constant, for example 7/22/44, 9/26/52 and 11/30/60. A stable result means that nearby settings give similar results. A lone best setting surrounded by poor ones usually means the search fitted noise.

Hypothetical example

A trader tests a cloud-breakout rule on 15-minute bars of an index future, with commission and slippage included. Profit factor is gross profit divided by gross loss. Eight of nine setting combinations show a profit factor between 1.05 and 1.20, each with 300 to 400 trades. One combination shows 1.60, but on only 40 trades. The 1.60 result is the one to distrust. The eight similar results describe the rule better, and their modest level is the honest estimate to carry forward.

Two hypothetical 3 by 3 grids of profit factor for Tenkan lengths 7, 9, 11 and Kijun lengths 22, 26, 30: the plateau grid has all nine cells between 1.05 and 1.20; the peak grid has eight cells between 1.05 and 1.20 with 300 to 400 trades each and one bright cell at 1.60 built on only 40 trades Plateau beats a lone peak Hypothetical, 9 settings each Plateau Peak 1.08 1.12 1.10 1.14 1.18 1.15 1.09 1.13 1.11 1.06 1.11 1.09 1.15 1.07 1.12 1.05 1.19 1.60 All 1.05–1.20 1.60: 40 trades Others: 300–400 The peak rests on 40 trades. So: carry the plateau forward.
Hypothetical settings grids. Right: the example above, where one bright cell built on only 40 trades stands out from eight similar results. The eight similar cells, like the plateau on the left, are the more honest description of the rule.

Research on backtest overfitting shows that the best result from many trials is biased upward, and the bias grows with the number of trials (Bailey et al., 2014; Harvey & Liu, 2015). So count how many combinations you tried, and confirm the chosen setting on data it was not tuned on. Walk-forward analysis does this by tuning on one window and testing on the next window, repeated across the history.

Where does the Ichimoku cloud struggle?

The Ichimoku cloud struggles in two predictable places: it reacts late to turns, and it gives many false signals when the market moves sideways. Both are built into the design, so measure them instead of hoping they are absent.

Lag. Every line is based on past bars, and the cloud under today's price was calculated 26 bars ago. Even though the cloud is drawn ahead, it contains no forecast. After a sharp reversal, a 52-bar midpoint can take many bars to move. A cloud breakout therefore tends to come after a large part of the move has already happened.

Trend dependence. In a range, price moves in and out of a thin cloud and Tenkan and Kijun cross back and forth. Each cross is a trade, and each trade pays commission and slippage.

Check these points in your results:

What to checkWhat a weak result looks like
Results by yearOne or two strong trending years produce almost all of the profit
Average trade versus round-trip costThe average trade before costs is only slightly larger than the cost
Trades taken inside or near a thin cloudMost of the losing trades sit there
Long and short sides separatelyOne side carries the whole result and the other loses

If losses gather in sideways periods, test a filter that skips thin clouds or low-trend conditions, and keep it only if it holds up on unseen data. The guide to trading costs in backtests explains how to compare the average trade with the cost per round trip. AlphaPrime's strategy validation runs walk-forward analysis with Basic, Standard or Extensive validation and your own thresholds, so a rule that only worked in one market phase can be identified before you spend more time on it.

What this means if you use AlphaPrime: write Ichimoku ideas as exact rules that use only values known at bar t, give the settings a range around 9, 26, 52 with costs included in the search, and keep the candidates that sit on a plateau and pass validation on unseen data.

Frequently asked questions

What are the best Ichimoku settings for day trading futures?

No setting is best for every market and timeframe. Start with 9, 26, 52, then test nearby combinations that keep a similar ratio, such as 7/22/44 and 11/30/60. Prefer settings whose neighbours give similar results, and confirm them on data they were not tuned on.

Is the Ichimoku cloud a leading or a lagging indicator?

All Ichimoku lines are calculated from past prices, so all of them lag. The cloud is drawn 26 bars ahead, but it is a projection of past ranges, not a forecast. Treat it as a description of recent trend and range.

Does the Chikou span use future data in a backtest?

The Chikou line itself is just the close drawn 26 bars back, so on a chart it does not change. The problem appears when a rule reads the Chikou value at today's bar, because that value is a close from 26 bars in the future. Write the rule as today's close compared with the close 26 bars ago.

Can you combine the Ichimoku cloud with other indicators?

Yes, traders often add a trend-strength or volatility filter to skip sideways periods. Each extra condition adds settings that can be fitted to noise. Test the combination as one strategy and check that it still holds up on unseen data.

References

  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
  • Harvey, C. R., & Liu, Y. (2015). Backtesting. The Journal of Portfolio Management, 42(1), 13–28.

What AlphaPrime does here

AlphaPrime's strategy generation turns ideas like cloud breakouts and TK crosses into testable rules with parameter ranges. AlphaPrime's backtesting evaluates them in batches with next-bar execution, fees and slippage, and strategy validation checks the survivors with walk-forward analysis and your own thresholds.

See plans and pricing