/*
ICHIMOKU CHART
A bullish signal occurs when the Tenkan-Sen (RED line) crosses the Kijun-Sen (BLUE line) from below.
Conversely, a bearish Signal is issued when the Tenkan-Sen crosses the Kijun-Sen from above.
Support and resistance levels are shown as Kumo (or clouds). The Kumo can also be used to help identify
the prevailing trend of the market. If the price line is above the Kumo, the prevailing trend is said to be up,
while if the price is below the Kumo, the prevailing trend is said to be down. The default colour here for the clouds is
light blue - but the hue, etc, parameters can be adjusted to suit the user's display.
The theory is that the bullish signals are strong when the TL,SL cross occurs above the cloud; it is medium within the
cloud, and weak if it occurs below the cloud. These are shown here as green solid up arrows, green up triangles and hollow
indigo up arrows respectiveley.
Conversely, the bearish signals are said to be strong when the cross is below the cloud and weak when above. These signals
are plotted as down red arrows or triangles, or brown hollw down arrows.
As an attempt at clarity on a cluttered plot, all signal arrows, etc are plotted within the clouds (rather than near the
candles as is normal). The user can also toggle between a candle plot or a line plot of the close price, to reduce
the clutter somewhat.
A final feature of the Ichimoku chart is the VIOLET line, or Chikou Span (or Lagging Span). It is said that this line
indicates the strength of the buy or sell signal. If the Chikou Span is below the closing price and a sell signal occurs,
then the strength is with sellers, otherwise it is a weak sell signal. Conversely, if a buy signal occurs and the Chikou
Span is above the price, then there is strength to the upside. These considerations could be coupled with the other
signals, if desired, but this has not been done here.
Final Comment: This program produces quite a pretty graph - but I have not so far been impressed with the signals!
I have seen many weak signals followed by strong moves and strong signals followed by weak moves. Typical of technical
analysis I guess. If anyone finds the Ichimoku approach useful I would be keen to hear about it.
*/
SL = ( HHV( H, 26 ) + LLV( L, 26) )/2;// standard, base, or kijun-sen line
TL = ( HHV( H, 9 ) + LLV( L, 9 ) )/2;// turning, conversion, or tenkan-sen line
DL = Ref( C, 25 ); // delayed close price, or chikou span
Span1 = Ref( ( SL + TL )/2, -25 ); //Span1 and Span2 define the clouds
Span2 = Ref( (HHV( H, 52) + LLV(L, 52))/2, -25);
CStyle = ParamToggle("Showcandles?","N|Y");//Choose Candle or Line for Price plot
hue = Param("Hue",140,0,255,1);
sat = Param("Sat",100,0,255,1);
bri = Param("bri",220,0,255,1);
MaxGraph = 8;
Refline = (Span1 + Span2)/2;
Graph0 = Refline;
Graph0Style = 16;//No line plotted, used as a reference line for arrows etc.
if(Cstyle )
Plot(C,"Price",colorBlack,styleCandle);
else
Plot(Close,"Close",colorBlack,styleThick);
Plot(SL,"SL",colorBlue,styleThick);
Plot(TL,"TL",colorRed,styleThick);
Plot(DL,"DL",colorViolet,styleLine);
PlotOHLC(Span1,Span1,Span2,Span2,"Cloud",ColorHSB(Hue,sat,bri),styleCloud);
above = IIf(TL>Span1 AND TL>Span2,1,0);
within = IIf((TL>Span1 AND TL<Span2) OR (TL<Span1 AND TL>Span2) ,1,0);
below = IIf(TL<Span1 AND TL<Span2,1,0);
Buy = Cross(TL,SL);
Sell = Cross(SL,TL);
StrongBuy = Buy AND above;
MediumBuy = Buy AND within;
WeakBuy = Buy AND below;
StrongSell = Sell AND below;
MediumSell = Sell AND within;
WeakSell = Sell AND above;
IIf( (StrongBuy),PlotShapes(shapeUpArrow*StrongBuy,colorGreen),0);
IIf( (MediumBuy),PlotShapes(shapeUpTriangle*MediumBuy,colorGreen),0);
IIf( (WeakBuy),PlotShapes(shapeHollowUpArrow*WeakBuy,colorIndigo),0);
IIf( (StrongSell),PlotShapes(shapeDownArrow*StrongSell,colorRed),0);
IIf( (MediumSell),PlotShapes(shapeDownTriangle*MediumSell,colorRed),0);
IIf( (WeakSell),PlotShapes(shapeHollowDownArrow*WeakSell,colorBrown),0);