OPEN-SOURCE SCRIPT
Diupdate

Ichimoku Status Panel - Projection and Price Targets

569
Ichimoku Status Panel - Projection and Price Targets

WHAT THIS IS

A read-only status panel for Ichimoku Kinko Hyo. It produces no buy or sell
signals and takes no view on direction. It reports what the chart currently
shows, in a form that is quicker to read than the lines themselves, and leaves
the judgement to the reader.

The panel is aimed at people who already trade with Ichimoku and want the
bookkeeping done for them: which conditions hold, for how long, and what is
already determined about the next few bars.


WHAT IT ADDS OVER A PLAIN ICHIMOKU

1. Projection of the Tenkan-sen and Kijun-sen.

The Tenkan-sen and Kijun-sen are midpoints of rolling high/low windows. That
means the bar on which the current extreme leaves the window is already known,
and so is the value the line will take once it does. The panel reports this as
"in N bars, up/down to X". Unless a new extreme is made in the meantime, that
move is settled in advance. A moving average cannot be read this way, and this
property is generally not surfaced by Ichimoku tools.

2. Chikou Span measured against the cloud, not only against price.

Most implementations compare the Chikou Span with the price 26 periods back
and stop there. Classical treatments also compare it with the cloud that sits
at that same location. A break of the cloud by price that is not confirmed by
the Chikou Span clearing the cloud behind it is a well documented failure
pattern. The panel shows this as a separate row, and calls out when the Chikou
Span is inside the cloud.

3. Counting that matches the original construction.

The original definition displaces by "26 periods including the current one",
which is a 25-bar shift. The script uses this by default and exposes a toggle
for anyone who prefers a plain 26-bar shift, so the reading can be matched to
whichever convention the rest of a workflow uses.

4. Construction from closes only, for indices.

Classical practice takes the intraday high and low, with the note that stock
indices remain valid when built from closes alone. Both are available.

5. Wave price targets, with a validity rule.

V, N, E and NT calculations from the last three alternating swing points, with
the percentage of the move already completed, and an option to hide targets
that price has passed. Consecutive swing points of the same kind are merged
into the more extreme one, so a usable wave is always available rather than
the display stalling whenever two highs or two lows confirm in a row.

More importantly, a wave whose starting point A has been taken out by price is
no longer a valid premise for a target. Pivots confirm several bars late, so
after a breakout the most recent completed wave often still runs against the
market, and every target it produces sits on the wrong side. When this happens
the script falls back to the preceding wave, which by construction runs the
other way, and the panel marks the condition. This keeps the levels on the
side the market is actually working toward.


PANEL ROWS

Bullish count how many of the six conditions currently hold
Price - Tenkan side, plus distance from the Tenkan-sen in percent
Tenkan - Kijun bullish or bearish, and how many bars it has held
Chikou - Price bullish or bearish, and how many bars it has held
Chikou - Kumo above, below, or inside the cloud behind price
Price - Kumo above, below, or inside the current cloud
Kijun slope rising, falling, or flat with a count of flat bars
Proj Tenkan bars until the Tenkan-sen moves, and to what value
Proj Kijun bars until the Kijun-sen moves, and to what value
Kumo twist bars until the next crossing of the leading spans
Bars since bars since the recent high and low, flagged when close to
the classical time numbers 9, 17, 26, 33, 42, 65 and 76
Wave the A, B and C points currently used for the targets,
marked when the preceding wave is in use or when the
starting point has been broken

All panel values are also written to the data window, so past bars can be
inspected by moving the cursor across the chart.


PRICE TARGET FORMULAS

With A as the start of the wave, B as the first objective and C as the
pullback or rally against it:

V = B + (B - C)
N = C + (B - A)
E = B + (B - A)
NT = C + (C - A)

The same four formulas serve both directions. In a down wave A is the starting
high, B the low and C the rally high, which makes the bracketed terms negative
and places the targets below B.

NT is off by default. Classical texts describe it as the rarest of the four,
and leaving all four on tends to produce a level near any price.


ON LAG AND REVISION

Swing points are found with a pivot lookback, so they confirm a number of bars
after the fact, set by "Swing sensitivity". Until a pivot confirms, the most
recent leg is not part of the wave, and the wave used for the targets can
change as new pivots arrive. The target lines move when it does. This is
inherent to identifying waves mechanically and is not hidden: the A, B and C
values in use are always shown in the panel so the reading can be checked.

The six conditions, the projections and the Kumo twist count are all evaluated
on confirmed values and do not revise.

Choosing the wave is a judgement in classical practice, not a calculation. The
automatic detection here is a convenience. Where it disagrees with the wave you
would have drawn, trust your own.


SETTINGS WORTH KNOWING

Wave selection "Latest valid" falls back to the preceding wave when
price takes out the starting point of the latest one.
"Latest only" always uses the most recent wave.
Swing sensitivity larger picks up larger waves, and confirms later
Target line length how far left the target lines are drawn
Panel theme the panel is opaque, so it stays readable on any
chart background; the theme is a preference
Draw the Ichimoku lines
turn this off if you already have the built-in
Ichimoku Cloud on the chart

The time-number flags on the "Bars since" row derive from calendar-based
reasoning in the original theory. They are meaningful on daily charts. On
intraday charts the rest of the panel still applies, but those flags are best
ignored.


CREDIT

Ichimoku Kinko Hyo was developed by Goichi Hosoda. The projection property,
the Chikou Span versus cloud relationship, the inclusive counting convention
and the four price target formulas are all part of the classical body of
theory. The code and the panel design are my own.
Catatan Rilis
We have revised the labeling of the Ichimoku Kinko Hyo lines.
 
Tenkan-sen (Conversion Line)
Kijun-sen (Base Line)
Senkou Span A (Leading Span A)
Senkou Span B (Leading Span B)
Chikou Span (Lagging Span)
Kumo (Cloud)
Catatan Rilis
Kata-fu candle patterns, with an orderly/disorderly distinction.

KATA-FU CANDLE PATTERNS

A secondary, classical reading of candle streaks, separate from the Ichimoku
lines themselves.

A streak of five or more same-direction candles is read in tiers of five,
seven and nine. Each tier is split into two cases:

Orderly the high, low, open and close all extend further in the
streak's direction on every candle, bar over bar
Disorderly the same streak length, but the body and the wicks do not
extend together, bar over bar

This is the stated point of difference from a plain candle count such as the
Sakata methods: two five-bar streaks can carry different weight depending on
whether the move was orderly or not. A doji does not break a streak; it is
absorbed into the count.

A second, separate pattern looks for a single opposite-colored candle
interposed inside an otherwise same-direction run: one bear candle inside a
six-day window bounding five bull candles, one bear candle inside an
eight-day window bounding seven bull candles, or two bear candles inside an
eleven-day window bounding nine bull candles (and the mirrored bear-trend
versions of each). The window's first and last candles must run with the
streak; the interposed candles must sit strictly inside it.

Both readings report whether the pattern followed a move of one period (26
bars) or more in the opposite direction, since classical treatments describe
the pattern as strongest when it does. This check compares the close 26 bars
before the streak started against the close at the streak's start, which is
a simplified proxy for a sustained prior move rather than a strict
bar-by-bar test, and is disclosed as such in the code comments.
Catatan Rilis
Update: Kata-fu candle patterns are now logged rather than shown live.

A streak of 5+ same-direction candles (or an interposed pattern) can only be
called confirmed once it ends, since it keeps changing while still running.
The panel now updates the Kata-fu and Interposed rows every bar while a
pattern is active, then freezes the last reading the moment it concludes,
showing how many bars ago it was confirmed. That reading stays on screen
until the next pattern of the same kind appears.

The direction of the logged pattern is now shown as a triangle in the mark
column (up for bull, down for bear) instead of being left blank.
Catatan Rilis
Kata-fu Quick Reference (from Lecture 54, "Summary of Kata-fu")

Plain streaks (bull / bear)
Pattern Condition Note
Orderly 5-bull or longer 5+ consecutive bull candles; body and wick both extend higher bar over bar Especially strong when it follows a decline of one period (26 bars) or more
Orderly 7-bull or longer 7+ consecutive bull candles, extending higher Ranks above a 5-bull streak
Orderly 9-bull or longer 9+ consecutive bull candles, extending higher Ranks above a 7-bull streak. Tends to appear in periods of relatively small price movement
Disorderly 5-bull or longer 5+ consecutive bull candles, but body and wick do not extend together Weaker than an orderly 5-bull streak
Disorderly 7-bull or longer 7+ consecutive bull candles, uneven Same as above
Disorderly 9-bull or longer 9+ consecutive bull candles, uneven Same as above
Orderly 5-bear or longer 5+ consecutive bear candles; body and wick both extend lower bar over bar Especially strong when it follows a rise of one period (26 bars) or more
Orderly 7-bear or longer 7+ consecutive bear candles, extending lower Ranks above a 5-bear streak
Orderly 9-bear or longer 9+ consecutive bear candles, extending lower Ranks above a 7-bear streak
Disorderly 5-bear 5+ consecutive bear candles, but uneven Weaker than an orderly 5-bear streak
Disorderly 7-bear 7+ consecutive bear candles, uneven Same as above
Disorderly 9-bear 9+ consecutive bear candles, uneven Tends to appear in periods of relatively small price movement
----------------------------------------------------------------------------
A "streak" requires at least 5 candles, ranked in three tiers of 5, 7 and 9. The source text values a small total range over the streak as the best case.

"Body" refers to the open-to-close range; "wick" refers to the high and low. Orderly means both extend in the streak's direction on every candle; disorderly means they do not move together.

Interposed patterns

Pattern Condition
1 bear in 5-bull or longer Within a 6-day window, one bear candle interposed, with 5 bull candles before and after extending higher
1 bear in 7-bull or longer Within an 8-day window, one bear candle interposed, with 7 bull candles extending higher
2 bears in 9-bull or longer Within an 11-day window, two bear candles interposed, with 9 bull candles extending higher
1 bull in 5-bear Within a 6-day window, one bull candle interposed, with 5 bear candles before and after extending lower
1 bull in 7-bear Within an 8-day window, one bull candle interposed, with 7 bear candles extending lower
2 bulls in 9-bear Within an 11-day window, two bull candles interposed, with 9 bear candles extending lower

The first and last candle of the window must run with the main direction; the interposed candle(s) must sit strictly inside it.
-----------------------------------------------------------------------------
Notes that apply throughout
A doji occurring within a streak does not break it; it is simply counted toward the streak's length.
The pattern carries more weight when it appears after a move of one period (26 bars) or more in the opposite direction.
A small total range is considered better than a large one; a large range tends to exhaust the move's strength in the streak itself.
The stated point of difference from the Sakata methods (such as the three-soldiers pattern, which is a plain candle count) is the orderly/disorderly distinction.
Catatan Rilis
Update: time theory, forecast lines, and a flip projection.

TIME THEORY (new panel row)

Counts bars elapsed since the most recent swing origin and flags the count
against the classical time numbers (9, 17, 26, 33, 42, 65, 76). It also keeps
the length of up to the last 10 completed swing legs and reports when the leg
currently forming matches one of them, which is the "corresponding number"
idea from the source text.

This can be measured either on the chart's own bars or on a higher timeframe.
The source text builds its time analysis on daily bars and introduces the
weekly treatment explicitly as a simplified method: less precise for pinning
down a date, but still worth having for locating periods where a change is
likely. The chart's own timeframe is therefore the default, with the higher
timeframe available as an alternative rather than shown alongside it. When set
to Higher, the timeframe is picked automatically at roughly five times the
chart's own, rounded to a real timeframe, or set manually.


FORECAST LINES

Two vertical lines are projected forward: one for the next classical time
number, one for the next matching leg length, drawn in different styles. They
mark periods where a change is more likely. They carry no direction: whether
a change would be up or down is not something the time reading answers, and
the other panel rows are there for that.

The positions are calendar estimates that ignore non-trading days, so they are
approximate, more so on coarse timeframes.

Two filters keep the reading honest. Legs shorter than a set length are
excluded from matching, since a match between two short legs is almost always
coincidence. And the lowest classical number to use can be raised, since 9 and
17 are crossed by nearly every leg.

An option draws lines only where both reasons point at a similar time. Where
two independent readings coincide, the timing has more behind it than either
alone. In practice this is rare, which is itself informative.


PAST CONFIRMATIONS

Optionally leaves a faded line wherever a forecast number was actually
reached, so past readings can be checked against what the market did. This is
off by default and meant for occasional review rather than permanent display:
left on, the lines accumulate until something always sits near any turn, which
defeats the purpose.

The same review is available without any lines at all, since every time theory
value is written to the data window. Moving the cursor back through history
shows the elapsed count, the next number and any match for each bar.


SWING MARKS

Optionally marks the points the time module treats as wave origins, each
labelled with the length of the leg that ended there. This is for checking the
sensitivity setting against your own reading of the chart. It has no
counterpart in the source text; the pivot detection is a stand-in for a
judgement the original leaves to the reader, and where it disagrees with the
wave you would have drawn, trust your own.


FLIP PROJECTION

The Tenkan-Kijun row now also reports when their order is due to flip. Since
the projection already gives the future value of both lines, the bar on which
one crosses the other can be read ahead. The two lines move at different
times, so this is checked both when the first one moves and when both have,
and it carries the same condition as the projection itself: it holds unless a
new extreme is made in the meantime.
Catatan Rilis
Update: alerts for kata-fu patterns.

Streaks and interposed patterns can now raise alerts.

A streak stays at five bars or more for as long as it runs, so alerting on
that state would fire on every bar. Instead an alert is raised only as a tier
is reached: once when the streak reaches five, again if it grows to seven, and
again at nine. Interposed patterns resolve within a single window, so they
alert on the day they complete.

What to alert on is set in the panel's own settings: which tier to start from,
whether to require an orderly streak, whether to require the pattern to follow
an opposing move of one period or more, bull streaks, bear streaks, and
whether interposed patterns are included. The orderly filter does not apply to
interposed patterns, which the source text does not split into orderly and
disorderly.

There are two routes, and only one should be used at a time or every pattern
alerts twice.

Enable "Enable kata-fu alerts" in the settings and create an alert whose
condition is "Any alert() function call". The message then carries the detail:
symbol, timeframe, orderly or disorderly, tier and length, the streak's total
range, and whether an opposing move preceded it.

Or pick "Kata-fu streak formed" or "Interposed pattern formed" directly from
the alert dialog's condition list. Simpler to set up, but the message is fixed
text.

Alerts fire on bar close, so a reading that appears mid-bar and is withdrawn
before the bar closes will not notify. On a daily chart this means the alert
arrives after the session ends.
Catatan Rilis
Update: consistent panel contrast, automatic theme, and projection bands.

READABILITY

Bearish states were previously dimmed. That reads as a verdict, which is not
what the panel is for: a line being below another is information of the same
weight as it being above. All six condition rows now use the same text
strength either way, and the mark in the right-hand column carries the
direction. Dimming is now reserved for the absence of information - a pattern
not yet confirmed, a twist outside the lookahead range, a wave whose starting
point has been broken.

The panel theme also has an Auto setting, now the default, which reads the
brightness of the chart background and picks its own palette. The panel is
opaque either way, so it stays legible on a white or a black chart without
changing the setting when the chart theme changes.


PROJECTION BANDS

The Tenkan-Kijun row now reports when the two lines are due to cross, read
from the projected values of both. Since they move at different times, this is
checked both when the first one moves and when both have.

No such projection can be made unconditional, and the panel does not pretend
otherwise. The Tenkan's nine-bar window sits inside the Kijun's twenty-six-bar
window, so a high large enough to top both windows leaves only the lows to
differ and forces the bullish order, while a deep enough low forces the
bearish one. Any projection can be overturned by one large move.

What can be stated exactly is the price band the projection holds within, and
that is now shown alongside each projection as [low-high]. These are the
extremes that will remain in the window once the current one drops out; while
price stays between them, the projection is settled, and the moment it passes
either the projection is replaced. The band is narrower than the current
window's own range, so this is a stricter condition than simply not making a
new high or low. Shown for both projected lines and for the crossover, where
the two bands overlap. It can be switched off if the rows read too long.
Catatan Rilis
Update: sanyaku reading in the panel header.

The header now reports the classical sanyaku condition alongside the count.
Sanyaku bullish is Tenkan above Kijun, the Chikou Span above price, and price
above the cloud, all holding at once; sanyaku bearish is all three failing at
once.

Nothing new is calculated for this. Each of the three already has its own row,
so the header simply reports their conjunction, and the rows below show why it
reads the way it does.

The three are a subset of the six conditions, so the count and the sanyaku
label do not move together. Six of six is always sanyaku bullish, but three of
six can be too, if the three that hold are these ones.
Catatan Rilis
Update: flat stretches of Senkou Span B are now emphasised.

Senkou Span B is the midpoint of the 52-bar high and low. A midpoint reads only
those two extremes, not what happened between them, which is why it can sit
perfectly still for long stretches while a moving average over the same bars
would drift with every close. A flat stretch is not a quiet market; it is a
market that has neither made a new 52-bar high nor a new 52-bar low. Price can
be moving a great deal inside that band and the line will not shift at all.

The longer such a stretch runs, the more the level says. It marks the middle of
a range price has been unable to leave for that many bars, and it is the level
half the participants over that span have transacted above and half below. The
classical treatments give the flat sections of this line particular weight as
support and resistance for exactly this reason, and note that price returning
to a long-standing flat level tends to meet the accumulated positioning around
it.

It also means a break carries information beyond the price at which it happens.
The level can only change once a new 52-bar extreme is made, so price leaving a
long flat stretch and holding outside it says the range that defined the level
has been broken, not merely that price is temporarily elsewhere. The line will
have to move.

Stretches running nine bars or more, after the classical unit, are now drawn at
full opacity while shorter ones stay faint. The threshold can be changed, and
the emphasis switched off.

One limit worth knowing: a stretch is only known to have run nine bars once the
ninth arrives, and a plot cannot repaint bars already drawn. The emphasis
therefore begins at the ninth bar of a stretch and extends backwards as it
grows, leaving the first eight faint. The left edge of the emphasised section
sits eight bars after the stretch actually began.
Catatan Rilis
I fixed a logic error.
Catatan Rilis
Adjusted the display while inside clouds to "Neutral."
Catatan Rilis
We have linked the number of periods in the time theory and the number of trading days in the wave theory to the existing setting of “counting the current day as the first day.” The Ichimoku Kinko Hyo was introduced in 1936, and this adjustment is intended to align with the concept used in its calculations—such as the high and low prices over the “past 9 days” or “past 26 days”—where the current day is counted as the first day.
Catatan Rilis
Update: a seventh condition, a gradient scale, and equality as its own state.

SEVENTH CONDITION

Price against the Kijun-sen now has its own row and counts toward the total,
which reads out of seven rather than six. It sits directly under the Tenkan row
and reports the same way: which side price is on, and how far from the line in
percent.

The two are correlated, so a count of seven is not seven independent readings.
Read the rows rather than the number when that matters.


GRADIENT SCALE

The header is now a fifteen-segment scale rather than a label. Neutral yellow
at the centre, deepening to red towards the left and green towards the right;
only the segment matching the current count is drawn at full opacity, the rest
stays faded. The count and the sanyaku reading sit alongside it on the same row.

It is a scale of where things stand, not a verdict. Conditions failing is
information of the same weight as conditions holding.


EQUALITY

Two lines can be exactly equal, and a two-state row had no way to say so. It
reported "Below" or "Bearish" instead, which then contradicted the sanyaku
reading, since that uses a strict comparison.

This is not a rare edge. The Tenkan and Kijun coincide exactly whenever the
9-bar and 26-bar windows share the same high and low, which happens after a
move sharp enough for the last nine bars to have made the whole 26-bar range.
The four comparison rows now report Equal as its own state.


SANYAKU

The definition in common circulation adds a condition to the Tenkan-Kijun
comparison: the Kijun must be flat or rising for the bullish reading, flat or
falling for the bearish one. In effect the Kijun must not point the other way.
That condition is now applied.

What to do when the two lines are exactly equal is not addressed by the
original or by the common definition, so the handling here is a judgement of my
own and is marked as such in the code. If the Kijun has a direction at that
point, the reading follows it. If the Kijun is also flat there is nothing left
to decide the direction, and no sanyaku is reported.


CLASSICAL NUMBERS

The set now runs 9, 17, 26, 33, 42, 51, 65, 76, 129, 172.

The compound numbers are built by subtracting the overlapping bar: nine days up
and nine days down counts the turn twice, so 9 doubled less one gives 17, and
tripled less two gives 26. By the same rule the two-period number is 26 + 26 - 1
= 51, not 52. Fifty-two is the Senkou Span B window, which belongs to the line
periods rather than to this series.

The numbers now live in one place in the code, so the elapsed-bar row, the
forecast lines and the next-target calculation all read the same set.


TOLERANCE ON THE ELAPSED ROW

How close a count has to sit to a classical number before it is flagged is now
a setting, three bars by default, and the row shows the offset: a count of 35
reads as 33+2. Where several numbers fall within tolerance the nearest is
taken. The forecast lines keep their own, tighter tolerance, since widening
that would only multiply the lines.

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.