StockFetcher Forums · Filter Exchange · Ichimoku charting<< 1 2 3 4 5 >>Post Follow-up
7 posts
msg #52068
Ignore mistlethrush
6/8/2007 12:46:41 AM

I developed a filter that produces Ichimoku Charts, and identifies securities where the Tenkan_Sen line crosses the Kijun_Sen line in an upward direction -- indicating a buy signal. It also identifies the strength of the signal based on the location of the crossover relative to the Kumo (cloud).

buy_ind - indicates strength of the buy signal based location of crossover. 3 - Very Strong (crossover occurs above the Kumo), 2 - Good Buy signal (crossover occurs within the Kumo), 1 - Fair buy signal (crossover occurs below Kumo).

above - for Very Strong buys (buy_ind of 3), this column indicates how high above the kumo the crossover occured. The values are normalized to a percent to eliminate errors of scale in price range. This column is sorted in a descending order to float all Very Strongs to the top and rank by delta between crossover and Kumo (presuming the greater the delta the stronger the buy). This column is irrelevant for buy_ind 2 or 1.

All relevant lines are plotted on the price chart (Tenkan_Sen, Kijun_Sen, Senkou Span A, Senkou Span B). I would have liked to shade the kumo (range between Senkou Spans A & B), however don't think it's possible -- drag.

1) Anyone know how to shade a range on the plots? I doubt it, but thought I'd ask.
2) Chikou Span is not included in the project. I don't find it terribly useful, and couldn't figure out how to code it (plots median prices for x number of days in the future. For example, on May 15, would show the median price for May 30. Obviously, the line genrated stops short of current date minus whatever x is -- unless it really can see into the future ;-)). If someone has any thought on how to accomplish this -- jump in.
3) Any suggestions for improvement, anyone else with Ichimoku charting code to share?

At last, the code:

Fetcher[/* Crap minimizer */
Average Volume (20) > 250000 and
close > 3.5 and

/* Tenkan-Sen line (Conversion Line) */
set {tshi, High 7 day High}
set {tslo, Low 7 day Low}
set {ts1, tshi+tslo}
set {Tenkan_Sen, ts1 / 2}

/* Kijun-Sen line (Base Line) */
set {kshi, High 22 day High}
set {kslo, Low 22 day Low}
set {ks1, kshi+kslo}
set {Kijun_Sen, ks1 / 2}

/* Senkou Span A line (Base Line) */
set {tshi2, High 7 day High 22 days ago}
set {tslo2, Low 7 day Low 22 days ago}
set {ts12, tshi2+tslo2}
set {ts2, ts12 / 2}
set {kshi2, High 22 day High 22 days ago}
set {kslo2, Low 22 day Low 22 days ago}
set {ks12, kshi2+kslo2}
set {ks2, ks12 / 2}
set {ssa1, ts2+ks2}
set {Senkou_A, ssa1 / 2}

/* Senkou Span B line */
set {ssbhi, High 22 day High 22 days ago}
set {ssblo, Low 22 day Low 22 days ago}
set {ssb1, ssbhi+ssblo}
set {Senkou_B, ssb1 / 2}

/* Tenkan_Sen relative to Kumo */
set {tsa1, max(Senkou_A, Senkou_B)}
set {tsa2, count(Tenkan_Sen > tsa1,1)}
set {tsa3, min(Senkou_A, Senkou_B)}
set {tsa4, count(Tenkan_Sen < tsa3,1)}

/* Strength Factor */
set {f1, Tenkan_Sen - tsa1}
set {f2, f1 / tsa1}
set {f3, f2 * 100}
set {f4, f3 * tsa2}

/* Strong Buy - Tenkan_Sen above Kumo */
set {strong, tsa2}

/* Weak Buy - Tenkan_Sen below Kumo */
set {weak, 0 - tsa4}

/* Establish Buy Indicator */
set {buy_ind_a, 2+strong}
set {buy_ind, buy_ind_a+weak}

draw Tenkan_Sen on plot price
draw Kijun_Sen on plot price
draw Senkou_A on plot price
draw Senkou_B on plot price

/* establish a crossover occurred */
Tenkan_Sen crossed above Kijun_Sen

add column buy_ind
add column f4 {above}
sort column 6 descending

Cheers (Boro forever),

174 posts
msg #60235
Ignore ham1198
3/5/2008 8:25:16 PM

...from SFO magazine:
Trading with Clouds
by: Brian Dolan

This Japanese charting system is a simple way to gauge a market’s directional trend and identify key support/resistance levels.

In the very likely event that this is your first encounter with ichimoku, your first reaction on hearing the term might be to say “Gesundheit.”

Bad jokes aside, ichimoku (ee-chee-moe-koo) charts offer a powerful tool for traders to identify overall market trends and pinpoint key levels of support and resistance that are unlikely to be revealed by other forms of technical analysis. Ichimoku has a strong following in Asian trading circles, especially in Japan where it originated, and is becoming increasingly popular among Western traders. I would strongly urge traders to consider incorporating ichimoku into their routines of technical analysis. (And not just in forex, but in other markets as well.) One of the real beauties of ichimoku is the speed and ease with which significant price levels are identified, making it an easy addition to any trader’s repertoire of analysis.

A Little Background
The full name of ichimoku analysis reveals its relative simplicity and utility: ichimoku kinko hyo translates into “one glance equilibrium chart” and is also frequently translated as “one glance cloud chart,” referring to the singular feature of ichimoku charts, the cloud. At its most basic level, ichimoku is a moving average-based trend identification system, so traders inclined toward moving averages should find it readily comprehensible. Ichimoku is also primarily a longer-term, strategic trade identifier and is best used with daily and weekly inputs, as opposed to intraday periods. But ichimoku is more powerful than typical moving average systems because it factors in time as a critical complement to price action, implicitly recognizing that trends have both a time and price component.

Key Components of Cloud Charts
At first glance, an ichimoku chart can be overwhelming, but a little perseverance can pay off. Ichimoku charts consist of five different lines overlaid on a daily candlestick chart. (I give both the Japanese name and the English translation, and combine them in subsequent references.) The fastest-moving average is the tenkan-sen, or conversion line, displayed in black on Figure 1. The tenkan/conversion line is calculated by averaging the highest high and the lowest low during the prior nine days, as opposed to using daily closing prices like most moving average systems do. Next is the kijun-sen, or base line, which is displayed in magenta on Figure 1. The kijun/base line is calculated similarly to the tenkan/conversion line, but uses 26 days as the period. Together, then, the tenkan/conversion line and the kijun/base line form a nine- and 26-day modified moving average system. So far, so good.

The third line is the senkou span A, or leading span 1, which is displayed in light green on Figure 1 and forms one of the boundaries of the cloud. The senkou span A/leading span 1 line is calculated by taking the average value of the sum of the tenkan/conversion line and the kijun/base line and then is projected 26 days into the future.

click image for larger view

The fourth line is the senkou span B, or leading span 2, which is displayed in dark green on Figure 1 and forms the other boundary of the cloud. The senkou B/leading span 2 is calculated by averaging the highest high and the lowest low over the prior 52 days. Then it is plotted 26 days into the future. Taken together, the two leading spans form another modified moving average system, using the average of the nine- and 26-day periods and the average of the prior 52 days, but are plotted into the future.

The space between the two leading spans, displayed in green dots on Figure 1, represents the cloud, or kumo in Japanese. The idea of projecting these two spans into the future is intended to capture the essence of a trend, which is that price movements need to be sustained over time. By taking past price developments and projecting them into the future, traders are given a preview of where the trend support or resistance lies.

The fifth and final line is the chikou span, or lagging span, shown in blue on Figure 1. The chikou/lagging span is simply today’s daily closing price projected into the past by 26 days. The chikou/lagging span gauges the strength of the signals generated by the other lines.

Historical and Cultural Context
You probably noted that ichimoku relies on only three different time periods in its calculations: nine, 26 and 52. Those periods stem from a historical quirk extant when the system was developed prior to WWII. Japanese financial markets used to be open for trading on Saturdays, meaning that the trading week was six days long. As a result, the number nine represents a week and a half of trading; 26 equals the number of trading days in a typical month (30 minus four Sundays); and 52 equals two months of trading days. Japanese markets now trade only five days per week and 22 days in a typical month, so some practitioners of ichimoku suggest revising the parameters to seven or eight, 22 and 44.

In my experience, however, the traditional default settings of nine, 26 and 52 have performed the best. I’ll leave it to you to examine the difference between the two sets of parameters by visual examination, but the charts in this article should offer some convincing examples of how well the traditional parameters function. The origins of ichimoku also favor only using daily charts as opposed to intraday periods, making it more of a long-term indicator.

That the old values seem to work best is part and parcel of why ichimoku, as with most other forms of technical analysis, works at all—because many traders follow it. Although ichimoku is still relatively new to Western markets, it is deeply ingrained in the Japanese trading community and has a massive following throughout Asia. Over the past couple of years, ichimoku has also increasingly caught on in Western markets and the traditional parameters of nine, 26 and 52 are still most widely used. To my thinking, traders are always better off using the most widely used parameters, rather than straying from the pack.

Trading Signals
Ichimoku charts provide a wealth of information to traders from just a quick glance. As a trend identification system, ichimoku charts easily depict the existence and direction of a trend based on where prices are relative to the cloud. If current prices are above the cloud, the trend is considered to be up; prices below the cloud point to a downtrend. When prices are in the cloud, the trend may be reversing or shifting into a trading range.

As a type of moving average system, ichimoku signals are generated by crossovers of the key lines. When the tenkan/conversion line crosses over the kijun/base line, it generates a buying signal. A signal to sell appears when the tenkan/conversion line crosses below the kijun/base line from above. But in ichimoku theory, all signals are not created equal, and this is where the cloud comes into play. If the two lines cross to the downside while current prices are above the cloud, only a weak sell signal is generated. If the downside crossover takes place when prices are inside the cloud, then it indicates a medium-strength sell signal. The strongest sell signal is generated when the downside crossover occurs while prices are below the cloud, essentially signaling that fresh weakness is now evident within an overall downtrend. The same guidelines apply to upside crossovers generating buy signals and the location of current prices to the cloud, with the strongest buy signal coming from an upside crossover while prices are above the cloud.

The chikou/lagging span provides yet another way to gauge the strength of the crossover signals given by the tenkan/conversion line and kijun/base lines. Recall that the chikou/lagging span is simply today’s closing price projected 26 days into the past, providing a clear look at today’s market level relative to earlier prices. If a sell signal is generated on a downside crossover and the chikou/lagging span is below the price candles, the signal is considered stronger. If a crossover to the upside occurs and the chikou/lagging span is above prices, greater credence is attached to the buy signal. Again, the idea is that a crossover in the direction of the overall trend is considered more powerful than one that is against the trend.

Good Old Support and Resistance
Ichimoku lines are also outstanding indicators of support and resistance whose price levels are calculated by charting systems that offer ichimoku. In the simplest terms, the four main ichimoku lines (excluding the chikou/lagging span) all offer support if price is above them and resistance if price is below them.

Looking at Australian dollar/Japanese yen (AUD/JPY) in Figure 2 as an example, the tenkan/conversion line crossed the kijun/base line to the downside at point A, triggering a medium sell, because prices were in the cloud. The cloud managed to contain prices for several days, with some slippage to the downside, but any attempts to rally were capped by the top of the cloud and kijun/base line just above it. A decisive break through the cloud bottom at point B, which was also echoed by a bearish engulfing line from candlestick analysis (circled), presaged a break to the downside.

Subsequent losses were extreme (this was during the midsummer mortgage-backed security/carry trade meltdown), but eventually a “tweezers bottom” candlestick formation suggested a bottom had been reached at point C. Attempts to rally were initially limited by resistance from the tenkan/conversion line, but prices eventually broke above and carried on neatly to the kijun/base line. Later selling was nicely contained by the tenkan/conversion line, though there were two daily closes below the tenkan/conversion line, at point D. (The first daily close below correctly signaled renewed weakness on the following day, but the second day’s candle formed a “hammer” signaling the down move was likely already over.)

The next day’s price advance broke above both the tenkan/conversion and the kijun/base lines, suggesting strength lay ahead. Subsequent price gains led the tenkan/conversion line to cross over the kijun/base line, generating a weak buy signal. Extreme gains followed (so much for the weak buy signal) and all pullback attempts were contained by the tenkan/conversion line on a daily closing basis. The rally eventually stalled at point E, followed by prices dropping back through the tenkan/conversion line, which then limited attempts to rally, signaling a likely drop to the kijun/base line next. The kijun/base line was broken on an intraday basis, at point F, but ultimately held on a daily closing basis.

That day’s price candle also formed another “hammer,” a reversal pattern after a down move, reinforcing the support from the kijun/base line and suggesting further strength ahead. The following rebound broke above the tenkan/conversion line and the kijun/base line contained the downside. The rally ended at point G, initially signaled from candlesticks by a bearish engulfing line (circled), but accelerated significantly once the tenkan/conversion line was broken several days later.

The sharp price moves unfolding were due to renewed upheaval in the financial sector, leading to another round of carry trade liquidations. Note that the resulting collapse in prices was effectively contained by the base of the cloud at point H. In other words, even as the financial world appeared to be coming apart at the seams, the ichimoku cloud managed to contain the collapse in prices. The beauty of ichimoku is that the cloud, which is projected into the future, was already formed at that level weeks ago, allowing alert traders to identify a potentially significant source of support even in the most volatile of conditions.

click image for larger view

As you can see, the thickness of the cloud fluctuates over time, reflecting current and past price volatility. The lower the volatility of current and prior price action, the thinner the cloud and the smaller the support or resistance zone. The higher the current and prior volatility, the thicker the cloud and the larger the zone of support/resistance will be. This trait coincides nicely with what traders intuitively know and expect—periods of low volatility typically result in sizable directional breakouts. As well, the more volatile current/recent prices are, the greater the likelihood of false breaks of support/resistance levels. Ichimoku accounts for this through a thicker cloud implicitly recognizing such volatility.

Trading in the Real World
It’s always easy to show a chart and point to how well a particular form of technical analysis works—in hindsight. But the real test is not only how it performs in real time, but also what predictive potential it holds. This is one area where ichimoku truly stands out. To provide another example of how traders can use ichimoku charts to look into the future, I share a recent episode where dollar/yen was testing the top of its cloud, but I held a fundamental view that ongoing financial market volatility, which had led to sharp declines in USD/JPY, was likely to persist and result in a failure.

Figure 3 shows USD/JPY testing the top of its cloud in late December 2007 (circled). In the weekly market outlook that I write each Friday for clients, I correctly noted on Dec. 14 that USD/JPY had come up a long way, but its cloud was falling rapidly and this should contain the upside, citing the price level of the top of the cloud. In the following week, the cloud top did contain USD/JPY’s advance through Thursday, but on the Friday before Christmas week, USD/JPY broke and closed above the cloud. I reluctantly acknowledged that fact in my weekly outlook of Dec. 21, but also cautioned that the break higher was troubling. Of all the yen pairs, only USD/JPY, euro/yen and New Zealand dollar/yen had finished above their clouds, while the others (AUD/JPY, Canadian dollar/yen and British pound/yen) were still well below the bottom of their clouds.

click image for larger view

My fundamental argument had not changed either—the losses and uncertainty in the financial sector were more likely to persist than suddenly evaporate overnight. As a result, I suggested that if USD/JPY does indeed fail above and drop back into the cloud, subsequent declines were likely to be extreme because the cloud level dropped sharply in the following week, and I noted the price of the bottom of the cloud in the next week as a target. Remember, the cloud and its price levels appear 26 days into the future. In the following week, USD/JPY fell back into the cloud and subsequently collapsed. As with other charting techniques, in ichimoku the failure to sustain a breakout frequently leads to sharp reversals in the opposite direction. In short, I had the right fundamental outlook, but jumped the gun by calling for a top without a drop below the tenkan/conversion line.

Where else might I have found a reason to expect a failure in USD/JPY? My fundamental rationale for a decline in USD/JPY hinged on continued downside volatility in U.S. equities, which had been the driver for weakness in the yen pairs. I later looked at ichimoku charts of major U.S. stock indexes and realized that their clouds had contained the stock market rebound, which just goes to show that ichimoku can be used effectively across multiple markets. Take another look at Figure 1; it’s an unlabeled chart of the S&P 500 from the same period to illustrate how the cloud contained the rebound in equities.

A New Tool
Ichimoku charts provide a powerful but relatively simple way to gauge a market’s directional trend and identify key support and resistance levels. Trading signals are generated by crossovers of the main ichimoku lines and breaks of the cloud. Traders can also use ichimoku to anticipate likely future price developments based on the location of the cloud. Whether people trade stocks, forex or anything else, they should strongly consider adding ichimoku to their regular routines of market research. Ichimoku is new enough in the West that not every charting service has it. However, prominent charting packages that offer it include ProSticks, CQG, Trader Made and MetaTrader. If traders’ chart providers do not have it, they should let them know they want ichimoku!

174 posts
msg #60236
Ignore ham1198
3/5/2008 8:33:09 PM

...about a year ago gurutrader made a great attempt to code this technique, the only thing is on the chart the "and draw senkou_b on plot price" doesn't show up. can anyone figure why?:

- Ignore guru_trader 2/24/2007 4:15:27 PM

and not otcbb
and avgvol(90) > 100000
and close between 1 and 250

/* Create Tenkan-Sen Conversion Line */
set{tenkan_sen_high, High 8 Day High}
set{tenkan_sen_low, Low 8 Day Low}
set{tenkan_sen_add,tenkan_sen_high + tenkan_sen_low}
set{tenkan_sen,tenkan_sen_add / 2}
and draw tenkan_sen on plot price

/* Create Kijun-Sen Base Line */
set{kijun_sen_high, High 22 Day High}
set{kijun_sen_low, Low 22 Day Low}
set{kijun_sen_add,kijun_sen_high + kijun_sen_low}
set{kijun_sen,kijun_sen_add / 2}
and draw kijun_sen on plot price

/* Create Chikou Span Lagging Line */
and draw chikou_span on plot price

/* Create Senkou Span A */
set{senkou_a_add,tenkan_sen + kijun_sen}
set{senkou_a_div,senkou_a_add / 2}
and draw senkou_a on plot price

/* Create Senkou Span B */
set{senkou_high, High 44 Day High}
set{senkou_low, Low 44 Day Low}
set{senkou_b_add,senkou_high + senkou_low}
set{senkou_b_div,senkou_b_add / 2}
and draw senkou_b on plot price

and tenkan_sen crossed above kijun_sen

2,817 posts
msg #60241
Ignore chetron
3/6/2008 6:36:42 AM

maybe you can't use a custom variable to set up a dma?

2,824 posts
msg #60245
Ignore nikoschopen
3/6/2008 11:23:54 AM

"[T]he only thing is on the chart the "and draw senkou_b on plot price" doesn't show up."

It shows up fine on mine. Do you currently have a basic or advanced subscription?

2,817 posts
msg #60252
Ignore chetron
3/6/2008 2:42:13 PM



174 posts
msg #60254
Ignore ham1198
3/6/2008 4:54:33 PM

nico, i get 4 lines, so 4 different colors, but senkou_b line doesn't show up. i can't determine the "cloud" between the senkou_a and senkou_b.

2,824 posts
msg #60255
Ignore nikoschopen
3/6/2008 5:01:40 PM

That's because "senkou_a" and "senkou_b" are identical as you can see in the image below.

2,824 posts
msg #60256
Ignore nikoschopen
3/6/2008 5:18:36 PM

Yup, as I sift through the filter, I noticed that Guru used dma(variable). That's currently not supported as far as I know. I wonder, however, if this is not a typo for cma(variable). Do you by chance have the original formula for this filter?

2,824 posts
msg #60257
Ignore nikoschopen
3/6/2008 6:23:44 PM

If it is indeed dma(variable), here's a way to get around the limitation: See the next post

StockFetcher Forums · Filter Exchange · Ichimoku charting<< 1 2 3 4 5 >>Post Follow-up

*** Disclaimer *** does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. does not recommend particular securities., Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.

Copyright 2018 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus