//+------------------------------------------------------------------+ //| i-Sadukey_v1.mq5 | //+------------------------------------------------------------------+ //---- indicator version #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //---- number of indicator buffers 3 #property indicator_buffers 3 //---- only 1 plot is used #property indicator_plots 1 //+-----------------------------------+ //| Indicator drawing parameters | //+-----------------------------------+ //---- drawing the indicator as a histogram #property indicator_type1 DRAW_COLOR_HISTOGRAM2 //---- gray, red, blue colors are used in the histogram #property indicator_color1 Gray,Red,Blue //---- indicator line is a solid one #property indicator_style1 STYLE_SOLID //---- the width of indicator line is 5 #property indicator_width1 5 //+----------------------------------------------+ //| Indicator input parameters | //+----------------------------------------------+ input int Shift=0; // Horizontal shift of the indicator in bars //+----------------------------------------------+ //---- declaration of dynamic arrays that // will be used as indicator buffers double ExtBuffer1[],ExtBuffer2[],ColorBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- set ExtBuffer1[] dynamic array as an indicator buffer SetIndexBuffer(0,ExtBuffer1,INDICATOR_DATA); //---- shifting the indicator horizontally by Shift PlotIndexSetInteger(0,PLOT_SHIFT,Shift); //---- performing the shift of beginning of indicator drawing PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,66); //---- restriction to draw empty values for the indicator PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); //---- set ExtBuffer2[] dynamic array as an indicator buffer SetIndexBuffer(1,ExtBuffer2,INDICATOR_DATA); //---- shifting the indicator horizontally by Shift PlotIndexSetInteger(1,PLOT_SHIFT,Shift); //---- performing the shift of beginning of indicator drawing PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,66); //---- restriction to draw empty values for the indicator PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); //---- set ColorBuffer[] dynamic array as a colored index buffer SetIndexBuffer(2,ColorBuffer,INDICATOR_COLOR_INDEX); //---- shifting the indicator horizontally by Shift PlotIndexSetInteger(2,PLOT_SHIFT,Shift); //---- performing the shift of beginning of indicator drawing PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,66); //---- initializations of variable for the indicator short name string shortname="i-Sadukey_v1"; //---- creating a name for displaying in a separate sub-window and in a tooltip IndicatorSetString(INDICATOR_SHORTNAME,shortname); //---- determination of accuracy of displaying the indicator values IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //---- } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, // number of bars in history at the current tick const int prev_calculated,// amount of history in bars at the previous tick const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //---- checking the number of bars to be enough for the calculation if(rates_total<66) return(0); //---- declarations of local variables int first; //---- Declaration of variables with a floating point double Vel1,Vel2,nVel1,nVel2; //---- calculation of the 'first' starting number for the bars recalculation loop if(prev_calculated>rates_total || prev_calculated<=0) // checking for the first start of calculation of an indicator { first=67; // starting index for calculation of all bars } else { first=prev_calculated-1; // starting number for calculation of new bars } //---- main indicator calculation loop for(int bar=first; barVel2)ColorBuffer[bar]=2; else if(Vel1