//+------------------------------------------------------------------+ //| iMovment.mq5 | //| Copyright dmffx.com | //| http://dmffx.com | //+------------------------------------------------------------------+ #property copyright "dmffx.com" #property link "http://dmffx.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 8 #property indicator_plots 1 #property indicator_label1 "Open;High;Low;Close" #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_color1 CLR_NONE // Price movement in points, considered as necessary for the change of the trend input int Movment=70; // Color of upward trend candles input color UpColor=Blue; // Color of "retracement" candles for the upward trend input color UpBackColor=White; // Color of downward trend candles input color DnColor=Red; // Color of "retracement" candles for the downward trend; input color DnBackColor=White; // To multiply the parameter Movment automatically by 10 for the 5- and 3-digit quotes. input bool Auto5Digits=true; double BOpen[]; double BHigh[]; double BLow[]; double BClose[]; double BColor[]; double BTrend[]; double BMin[]; double BMax[]; int Grad=10; color Colors[]; double Movment2; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { Movment2=Movment; if(Auto5Digits) { if(_Digits==5 || _Digits==3) { Movment2*=10; } } SetIndexBuffer(0,BOpen,INDICATOR_DATA); SetIndexBuffer(1,BHigh,INDICATOR_DATA); SetIndexBuffer(2,BLow,INDICATOR_DATA); SetIndexBuffer(3,BClose,INDICATOR_DATA); SetIndexBuffer(4,BColor,INDICATOR_COLOR_INDEX); SetIndexBuffer(5,BTrend,INDICATOR_CALCULATIONS); SetIndexBuffer(6,BMin,INDICATOR_CALCULATIONS); SetIndexBuffer(7,BMax,INDICATOR_CALCULATIONS); PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,0); ArrayResize(Colors,Grad*2); color Col1=PlotIndexGetInteger(0,PLOT_LINE_COLOR,0); color Col2=PlotIndexGetInteger(0,PLOT_LINE_COLOR,1); PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,Grad*2); for(int i=0;i0) { limit=prev_calculated-1; } else { limit=1; } for(int i=limit;iBMax[i]) { BMax[i]=close[i]; } ColInd=(int)MathCeil(10.0*(BMax[i]-close[i])/(_Point*Movment2)); if(ColInd>=Grad) { BTrend[i]=-1; BMin[i]=close[i]; ColInd=0; } else { ColInd+=Grad; } break; case 0: BOpen[i]=0; BHigh[i]=0; BLow[i]=0; BClose[i]=0; if(close[i]>BMax[i]) { BMax[i]=close[i]; } if(close[i]=BMin[i]+_Point*Movment2) { BTrend[i]=1; BMax[i]=close[i]; } break; case -1: if(close[i]=Grad) { BTrend[i]=1; BMax[i]=close[i]; ColInd=Grad; } break; } BColor[i]=ColInd; } return(rates_total); } //+------------------------------------------------------------------+ color GetColor(double aK,int Col1,double Col2) { int R1,G1,B1,R2,G2,B2; fGetRGB(R1,G1,B1,Col1); fGetRGB(R2,G2,B2,Col2); return(fRGB(R1+aK*(R2-R1),G1+aK*(G2-G1),B1+aK*(B2-B1))); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void fGetRGB(int &aR,int &aG,int &aB,int aCol) { aB=aCol/65536; aCol-=aB*65536; aG=aCol/256; aCol-=aG*256; aR=aCol; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ color fRGB(int aR,int aG,int aB) { return(aR+256*aG+65536*aB); } //+------------------------------------------------------------------+