#property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 Green #property indicator_color3 Yellow double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; int width; extern int Rperiod=34; extern int Draw4HowLongg=1500; int Draw4HowLong; int shift; int i; int loopbegin; double sum[]; int length; double lengthvar; double tmp ; double wt[]; int c; int init() { IndicatorBuffers(5); SetIndexBuffer(0,ExtMapBuffer1); SetIndexBuffer(1,ExtMapBuffer2); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,2); SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,2); SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,2); SetIndexArrow(0,159); SetIndexArrow(1,159); SetIndexArrow(2,159); SetIndexBuffer(3,sum); SetIndexBuffer(4,wt); return(0); } int start() { Draw4HowLong=Bars-Rperiod - 5; length=Rperiod; loopbegin=Draw4HowLong - length - 1; for(shift=loopbegin; shift>=0; shift--) { sum[1]=0; for(i=length; i>=1 ;i--) { lengthvar=length + 1; lengthvar/=3; tmp=0; tmp =(i - lengthvar)*Close[length-i+shift]; sum[1]+=tmp; } wt[shift]=sum[1]*6/(length*(length+1)); ExtMapBuffer1[shift]=wt[shift]; ExtMapBuffer2[shift]=wt[shift]; ExtMapBuffer3[shift]=wt[shift]; if(wt[shift+1] < wt[shift]){ ExtMapBuffer3[shift]=EMPTY_VALUE; } if(wt[shift+1] > wt[shift]){ ExtMapBuffer3[shift]=EMPTY_VALUE; ExtMapBuffer2[shift]=EMPTY_VALUE; } ExtMapBuffer1[shift+1]=wt[shift+1]; ExtMapBuffer2[shift+1]=wt[shift+1]; ExtMapBuffer3[shift+1]=wt[shift+1]; if (wt[shift+1] > wt[shift] && wt[shift+2] > wt[shift+1]) { ExtMapBuffer2[shift+1]=EMPTY_VALUE; ExtMapBuffer3[shift+1]=EMPTY_VALUE; } else if (wt[shift+1] < wt[shift] && wt[shift+2]< wt[shift+1]) { ExtMapBuffer1[shift+1]=EMPTY_VALUE; ExtMapBuffer3[shift+1]=EMPTY_VALUE; } } return(0); } //+------------------------------------------------------------------+