Ready to go further
Next: learn the trap behind many variants
The overfitting guide explains why the best of many tries tells you less than it seems, and how to spot it in a backtest.
What is included
- What it is, in plain words
- The formula or mechanism, with exact arithmetic
- How it hits grid, martingale and DCA bots
- A check you can run before you switch a bot on
Who it is for
- People who run or plan to run a trading bot
- Anyone reading a backtest or a bot sales page
- Readers who want the numbers, not the pitch
- Not advice, and not a signal service
Key facts
- An Ichimoku cloud strategy is not one rule. It is a family of rules built from five lines, and each choice you make about them is a setting a bot has to test.
- The two most common building blocks are price against the cloud edges and the tenkan line against the kijun line. Each can be a filter, a trigger or an exit.
- On the made-up bar below, the close is 102.77 and the cloud runs from 99.60 to 103.31, so the close is inside the cloud (calculated by us on 31 Oct 2026, exact).
- With the option lists on this page there are 102 rule variants at fixed periods, and 102,000 if each of the three periods can take ten values. Trying many and keeping the best is how overfitting happens.
- A fair test uses data the settings never saw, counts trades, includes costs, and treats a handful of trades as too few to conclude anything.
From a chart idea to a rule a bot can run
The basic definitions of the five lines are on the Ichimoku cloud page. Here is the short version, only so the rules below make sense. The tenkan is the midpoint of the highest high and lowest low of the last 9 bars. The kijun is the same over 26 bars. Span A is the average of those two, drawn 26 bars ahead. Span B is the midpoint over 52 bars, also drawn 26 bars ahead. The chikou is the close drawn 26 bars back. The area between span A and span B is the cloud.
A person looking at a chart does not need more than that. A bot does. "Price is above the cloud" can mean the close, the high or the low. It can mean above the upper edge, or above both edges on this bar, or above the cloud that was plotted ahead of the bar. "The tenkan crossed the kijun" can mean it is above now, or that it was below on the last bar and is above on this one. Each wording gives different trades.
So the first job is to pick one meaning for each phrase and write it as a comparison on numbers. Here are the building blocks most Ichimoku rules use.
- Price versus cloud. Long filter: the close is above the larger of span A and span B on this bar. Short filter: the close is below the smaller of the two. Inside the cloud: neither, so the filter is off.
- Tenkan and kijun. Either a state (the tenkan is above the kijun) or an event (it was below on the last bar and is above now). The state is true for many bars. The event is true for one bar.
- Chikou. The close is above the close from 26 bars ago, which is the chikou test in plain numbers.
- Exit. The opposite cross, the close falling back into the cloud, or the close falling below the kijun. Without an exit rule a bot has an entry and no way out.
Two points about timing. The cloud on a bar is built from values 26 bars old, so it is known in advance and a rule using it today is not looking ahead. The chikou is different: it is plotted 26 bars back, but the value is today's close. A bot must compare today's close with the close from 26 bars ago, not read a plotted point as if it were old data. Getting this wrong is a form of look-ahead bias.
A worked example on a made-up bar
The prices here are made up. The path is 260 closes built from a slow rise plus three waves, and each high and low sits 0.8 either side of its close. All the arithmetic below was run in node on 31 Oct 2026 and is exact for this path. Take bar 120 and the standard 9, 26 and 52 settings.
| Quantity | Value at bar 120 | How it is found |
|---|---|---|
| Close | 102.77 | The closing price of the bar |
| Tenkan (9) | 107.49 | Midpoint of the highest high and lowest low of the last 9 bars |
| Kijun (26) | 109.30 | Same, over 26 bars |
| Span A | 103.31 | Average of tenkan and kijun, taken from bar 94 |
| Span B | 99.60 | 52-bar midpoint, taken from bar 94 |
| Cloud top | 103.31 | The larger of span A and span B |
| Cloud bottom | 99.60 | The smaller of span A and span B |
Now test the two rules. Rule one: the close is above the cloud top. 102.77 against 103.31: the close is inside the cloud, so rule one is false. Rule two: the tenkan is above the kijun. 107.49 against 109.30: rule two is false. A rule that needs both is false on this bar, so a long-only version of that rule would be flat at this close.
How many rules are there, really?
Count the choices from the list above. This is a made-up counting exercise, but the arithmetic is exact.
| Choice | Options | What they are |
|---|---|---|
| Price versus cloud | 3 | Off, above the cloud, above a rising cloud |
| Tenkan and kijun | 3 | Off, tenkan above kijun, fresh cross only |
| Chikou | 2 | Off, close above the close 26 bars ago |
| Exit | 3 | Opposite cross, back inside cloud, below kijun |
| Direction | 2 | Long only, long and short |
| Period sets | 5 | Five hand-picked (tenkan, kijun, span B) triples |
Multiply the first five rows: 3 x 3 x 2 x 3 x 2 = 108. Remove the 6 variants with every filter switched off, because they have no entry. That leaves 102. Multiply by the five period sets and you get 510. If instead each of the three periods can be any of ten values, there are 1,000 period sets and 102,000 variants.
Why many variants invite overfitting
Suppose a bot tries all the variants on the same history and keeps the one with the best result. Some variant will always come out on top. The question is whether it came out on top because it describes something real, or because with so many tries one of them was bound to line up with the quirks of that stretch of prices. From the result alone you cannot tell. This is overfitting, and the more variants you try, the less the best result tells you.
A small honest test on the made-up path
Here is the shape of a fair test, run on the same made-up path. Split the history in two. Part A is bars 77 to 167, where all the lines exist and the settings may be chosen. Part B is bars 168 to 258, which is locked away until the choice is made. The bot holds one unit when its rule is true at a close, and is flat otherwise. Each change of position costs 0.1 points. Results are in points per unit. The settings come from four period sets and three rule types, twelve rows in all, so this is a very small search compared with the counts above.
| Periods | Rule | Part A result | Part A trades | Part B result | Part B trades |
|---|---|---|---|---|---|
| 9/26/52 | Price above cloud | -0.98 | 4 | 8.15 | 3 |
| 9/26/52 | Tenkan above kijun | 5.47 | 3 | 19.26 | 3 |
| 9/26/52 | Both | -1.08 | 4 | 14.41 | 3 |
| 7/22/44 | Price above cloud | -0.36 | 3 | 11.35 | 3 |
| 7/22/44 | Tenkan above kijun | 8.51 | 3 | 20.99 | 3 |
| 7/22/44 | Both | 0.01 | 3 | 17.46 | 3 |
| 12/30/60 | Price above cloud | -6.83 | 4 | 4.04 | 7 |
| 12/30/60 | Tenkan above kijun | -4.12 | 3 | 12.63 | 3 |
| 12/30/60 | Both | -5.53 | 4 | 7.99 | 5 |
| 5/15/40 | Price above cloud | 3.66 | 3 | 15.30 | 3 |
| 5/15/40 | Tenkan above kijun | 4.86 | 7 | 28.64 | 3 |
| 5/15/40 | Both | -0.49 | 5 | 18.70 | 3 |
In Part A, 5 of the 12 rows finished above zero. The best Part A row was 7/22/44, tenkan above kijun, at 8.51 points. Applied to Part B, that same row gave 20.99 points. The best Part B row was 5/15/40, tenkan above kijun, at 28.64 points. So even in a search of only twelve rows, the winner in the first part and the winner in the second part were different rows.
Look at the trade counts as well. Every row made between 3 and 7 trades in a part. With so few trades, one more or one fewer changes the total a lot, and nothing here can be called a pattern. This is a made-up path chosen to show the method. It says nothing about how any rule behaves on real prices.
How to test it honestly
- Write the rule first. Fix the wording, the settings and the exit before looking at results. Keep a list of every variant you try.
- Keep data back. Choose on one part and test once on another. The how to backtest guide shows the steps.
- Roll the window. Walk-forward testing repeats the choose-then-test step across many windows, so one lucky stretch cannot decide.
- Include costs. The cross rules change position often when the price chops sideways. Add the spread, fees and slippage for your market. They vary by broker or exchange, so check yours.
- Look beyond the total. Check the trade count, the worst losing run and the largest fall from a peak. A good total with one huge winner is fragile.
- Check neighbours. If a 9, 26 and 52 rule works and a 10, 27 and 54 rule collapses, the first result was probably a fit to noise. A rule worth studying works across a range of nearby settings.
What it does not tell you
A set of Ichimoku rules describes what the price did relative to its own past. It does not say what comes next. A backtest, even a careful one, shows what a rule would have done on data already seen. It cannot show that the same behaviour will repeat. This page is education about how to turn a chart idea into something testable, not a signal and not advice.
Keep Going
Related Tools and Guides
Keep exploring
FAQ
Frequently Asked Questions
What is an Ichimoku cloud strategy?
It is a set of rules built from the Ichimoku lines, such as price against the cloud and the tenkan against the kijun. Many different rules go by that name, so a bot needs the exact comparison written down.
Which Ichimoku rule should a bot use?
This page cannot say which, and none is shown to work here. The point is to write each rule precisely, count the variants, and test them on data the settings never saw.
Why does trying many Ichimoku settings cause overfitting?
The best of many tries will look good on the history it was picked from, partly by luck. The more variants tried, the less that best result says about the future.
Are the default 9, 26 and 52 periods special?
They are the usual settings and nothing more. Changing them changes the trades, so they are one setting among many, and they should be tested like any other.
How many trades do I need before trusting a backtest?
No fixed number makes a result safe. With only a few trades, one more or less changes the outcome a lot, so treat small counts as too few to conclude anything.
Are the numbers on this page real?
Example numbers are made up to show how the maths works, and the page says so. A figure only counts as exact when the page says it was calculated on a stated date. Nothing you enter in a calculator leaves your browser.
Can I use this to decide whether to run a bot?
It can show whether a bot's numbers hold together and how much an account can lose. It cannot say what the market will do, and it is not advice. Use it to ask better questions, then read the terms of your own broker or exchange.
Is this financial advice?
No. It is general education about how to write and test rules. The prices are made up, and nothing here is a signal or a forecast.
Know the Risk Before You Run It
Free calculators and guides, added every week. Leave your details and we will email you when new ones go up.
Trading carries a risk of loss