//+------------------------------------------------------------------+ //| Ichimoku.mq5 | //| Copyright 2009, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "2009, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property description "Ichimoku Kinko Hyo" //--- indicator settings #property indicator_chart_window #property indicator_buffers 5 #property indicator_plots 4 #property indicator_type1 DRAW_FILLING #property indicator_type2 DRAW_LINE #property indicator_type3 DRAW_LINE #property indicator_type4 DRAW_LINE #property indicator_color1 SandyBrown,Thistle #property indicator_color2 Red #property indicator_color3 Blue #property indicator_color4 Lime #property indicator_label1 "Senkou Span A;Senkou Span B" #property indicator_label2 "Tenkan-sen" #property indicator_label3 "Kijun-sen" #property indicator_label4 "Chinkou Span" //--- input parameters input int InpTenkan=9; // Tenkan-sen input int InpKijun=26; // Kijun-sen input int InpSenkou=52; // Senkou Span B //--- indicator buffers double ExtTenkanBuffer[]; double ExtKijunBuffer[]; double ExtSpanABuffer[]; double ExtSpanBBuffer[]; double ExtChinkouBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ExtSpanABuffer,INDICATOR_DATA); SetIndexBuffer(1,ExtSpanBBuffer,INDICATOR_DATA); SetIndexBuffer(2,ExtTenkanBuffer,INDICATOR_DATA); SetIndexBuffer(3,ExtKijunBuffer,INDICATOR_DATA); SetIndexBuffer(4,ExtChinkouBuffer,INDICATOR_DATA); //--- IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1); //--- sets first bar from what index will be drawn PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpSenkou); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpTenkan); PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpKijun); //--- lines shifts when drawing PlotIndexSetInteger(0,PLOT_SHIFT,InpKijun); PlotIndexSetInteger(3,PLOT_SHIFT,-InpKijun); //--- change labels for DataWindow PlotIndexSetString(1,PLOT_LABEL,"Tenkan-sen("+string(InpTenkan)+")"); PlotIndexSetString(2,PLOT_LABEL,"Kijun-sen("+string(InpKijun)+")"); //--- sets drawing line empty value PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0.0); PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0.0); //--- initialization done } //+------------------------------------------------------------------+ //| get highest value for range | //+------------------------------------------------------------------+ double Highest(const double&array[],int range,int fromIndex) { double res=0; //--- res=array[fromIndex]; for(int i=fromIndex;i>fromIndex-range && i>=0;i--) { if(resfromIndex-range && i>=0;i--) { if(res>array[i]) res=array[i]; } //--- return(res); } //+------------------------------------------------------------------+ //| Ichimoku Kinko Hyo | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total,const int prev_calculated, const datetime &Time[], const double &Open[], const double &High[], const double &Low[], const double &Close[], const long &TickVolume[], const long &Volume[], const int &Spread[]) { int limit; //--- if(prev_calculated==0) limit=0; else limit=prev_calculated-1; //--- for(int i=limit;i