1 //+------------------------------------------------------------------+
\r
3 //| Copyright © 2004, MetaQuotes Software Corp. |
\r
4 //| http://www.metaquotes.net/ |
\r
5 //+------------------------------------------------------------------+
\r
6 #property copyright "Copyright © 2004, MetaQuotes Software Corp."
\r
7 #property link "http://www.metaquotes.net/"
\r
9 #property indicator_chart_window
\r
10 #property indicator_buffers 7
\r
11 #property indicator_color1 Red
\r
12 #property indicator_color2 Blue
\r
13 #property indicator_color3 SandyBrown
\r
14 #property indicator_color4 Thistle
\r
15 #property indicator_color5 Lime
\r
16 #property indicator_color6 SandyBrown
\r
17 #property indicator_color7 Thistle
\r
18 //---- input parameters
\r
19 extern int Tenkan=9;
\r
20 extern int Kijun=26;
\r
21 extern int Senkou=52;
\r
23 double Tenkan_Buffer[];
\r
24 double Kijun_Buffer[];
\r
25 double SpanA_Buffer[];
\r
26 double SpanB_Buffer[];
\r
27 double Chinkou_Buffer[];
\r
28 double SpanA2_Buffer[];
\r
29 double SpanB2_Buffer[];
\r
32 //+------------------------------------------------------------------+
\r
33 //| Custom indicator initialization function |
\r
34 //+------------------------------------------------------------------+
\r
38 SetIndexStyle(0,DRAW_LINE);
\r
39 SetIndexBuffer(0,Tenkan_Buffer);
\r
40 SetIndexDrawBegin(0,Tenkan-1);
\r
41 SetIndexLabel(0,"Tenkan Sen");
\r
43 SetIndexStyle(1,DRAW_LINE);
\r
44 SetIndexBuffer(1,Kijun_Buffer);
\r
45 SetIndexDrawBegin(1,Kijun-1);
\r
46 SetIndexLabel(1,"Kijun Sen");
\r
48 a_begin=Kijun; if(a_begin<Tenkan) a_begin=Tenkan;
\r
49 SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT);
\r
50 SetIndexBuffer(2,SpanA_Buffer);
\r
51 SetIndexDrawBegin(2,Kijun+a_begin-1);
\r
52 SetIndexShift(2,Kijun);
\r
53 SetIndexLabel(2,NULL);
\r
54 SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
\r
55 SetIndexBuffer(5,SpanA2_Buffer);
\r
56 SetIndexDrawBegin(5,Kijun+a_begin-1);
\r
57 SetIndexShift(5,Kijun);
\r
58 SetIndexLabel(5,"Senkou Span A");
\r
60 SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT);
\r
61 SetIndexBuffer(3,SpanB_Buffer);
\r
62 SetIndexDrawBegin(3,Kijun+Senkou-1);
\r
63 SetIndexShift(3,Kijun);
\r
64 SetIndexLabel(3,NULL);
\r
65 SetIndexStyle(6,DRAW_LINE,STYLE_DOT);
\r
66 SetIndexBuffer(6,SpanB2_Buffer);
\r
67 SetIndexDrawBegin(6,Kijun+Senkou-1);
\r
68 SetIndexShift(6,Kijun);
\r
69 SetIndexLabel(6,"Senkou Span B");
\r
71 SetIndexStyle(4,DRAW_LINE);
\r
72 SetIndexBuffer(4,Chinkou_Buffer);
\r
73 SetIndexShift(4,-Kijun);
\r
74 SetIndexLabel(4,"Chinkou Span");
\r
78 //+------------------------------------------------------------------+
\r
79 //| Ichimoku Kinko Hyo |
\r
80 //+------------------------------------------------------------------+
\r
84 int counted_bars=IndicatorCounted();
\r
85 double high,low,price;
\r
87 if(Bars<=Tenkan || Bars<=Kijun || Bars<=Senkou) return(0);
\r
91 for(i=1;i<=Tenkan;i++) Tenkan_Buffer[Bars-i]=0;
\r
92 for(i=1;i<=Kijun;i++) Kijun_Buffer[Bars-i]=0;
\r
93 for(i=1;i<=a_begin;i++) { SpanA_Buffer[Bars-i]=0; SpanA2_Buffer[Bars-i]=0; }
\r
94 for(i=1;i<=Senkou;i++) { SpanB_Buffer[Bars-i]=0; SpanB2_Buffer[Bars-i]=0; }
\r
98 if(counted_bars>Tenkan) i=Bars-counted_bars-1;
\r
101 high=High[i]; low=Low[i]; k=i-1+Tenkan;
\r
105 if(high<price) high=price;
\r
107 if(low>price) low=price;
\r
110 Tenkan_Buffer[i]=(high+low)/2;
\r
115 if(counted_bars>Kijun) i=Bars-counted_bars-1;
\r
118 high=High[i]; low=Low[i]; k=i-1+Kijun;
\r
122 if(high<price) high=price;
\r
124 if(low>price) low=price;
\r
127 Kijun_Buffer[i]=(high+low)/2;
\r
130 //---- Senkou Span A
\r
132 if(counted_bars>a_begin-1) i=Bars-counted_bars-1;
\r
135 price=(Kijun_Buffer[i]+Tenkan_Buffer[i])/2;
\r
136 SpanA_Buffer[i]=price;
\r
137 SpanA2_Buffer[i]=price;
\r
140 //---- Senkou Span B
\r
142 if(counted_bars>Senkou) i=Bars-counted_bars-1;
\r
145 high=High[i]; low=Low[i]; k=i-1+Senkou;
\r
149 if(high<price) high=price;
\r
151 if(low>price) low=price;
\r
154 price=(high+low)/2;
\r
155 SpanB_Buffer[i]=price;
\r
156 SpanB2_Buffer[i]=price;
\r
159 //---- Chinkou Span
\r
161 if(counted_bars>1) i=Bars-counted_bars-1;
\r
162 while(i>=0) { Chinkou_Buffer[i]=Close[i]; i--; }
\r
166 //+------------------------------------------------------------------+