//+------------------------------------------------------------------+ //| Renko.mq4 | //| * | //| * | //+------------------------------------------------------------------+ #property copyright "http://dmffx.com" #property link "http://dmffx.com" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 DodgerBlue #property indicator_color2 Red #property indicator_color3 Black #property indicator_width1 3 #property indicator_width2 3 #property indicator_width3 3 //---- input parameters extern int BoxSize = 10; extern int Reverse = 2; double bs; //---- buffers double VAL[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double ExtMapBuffer5[]; double RB[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(5); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,ExtMapBuffer3); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,ExtMapBuffer4); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(2,ExtMapBuffer5); SetIndexBuffer(3,VAL); SetIndexBuffer(4,RB); Reverse--; if(Reverse<0)Reverse=0; bs=Point*BoxSize; SetIndexEmptyValue(0,0); SetIndexEmptyValue(1,0); SetIndexEmptyValue(2,0); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start(){ static int S; static double LastTime,cH,cL,cD,pH,pL,pD; int cb=IndicatorCounted(),limit=Bars-cb-1; if(cb==0){ pH=0; cH=0; pL=0; cL=0; pD=0; cD=0; ArrayInitialize(VAL,0); ArrayInitialize(ExtMapBuffer3,0); ArrayInitialize(ExtMapBuffer4,0); ArrayInitialize(ExtMapBuffer5,0); ArrayInitialize(RB,0); } for(int i=limit;i>=0;i--){ if(Time[i]>LastTime){ LastTime=Time[i]; pH=cH; pL=cL; pD=cD; } else{ cH=pH; cL=pL; cD=pD; } RB[i]=RB[i+1]; int BoxNum=MathFloor(Close[i]/bs); switch(cD){ case 0: if(i==Bars-1){ cH=BoxNum; cL=BoxNum; } else{ cH=MathMax(cH,BoxNum); cL=MathMin(cL,BoxNum); if(BoxNumcL+Reverse){ cD=1; cH=BoxNum; RB[i]=Bars-i; S=RB[i]; } } break; case 1: cH=MathMax(cH,BoxNum); VAL[i]=cH; if(BoxNumcL+Reverse){ cD=1; cH=BoxNum; VAL[i]=cH; RB[i]=Bars-i; } break; } } //return(0); int RevInd=0,pRevInd=-1; double SV,EV; int ii=0; while(RB[RevInd]!=S && iiEV){ for(int x=SV;x>=EV+1 && ii