#property copyright "Copyright © 2009, MaGooLaboratory" #property link "http://xxx.com.br" #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 Lime #property indicator_color2 White #property indicator_color3 White #property indicator_color4 White #property indicator_color5 White #property indicator_color6 White //---- input parameters extern int Z1StepSize = 900; extern int Z1StepA = 700; extern int Z1Advance = 0; extern bool Z1HighLow = true; extern int Z1BarsNumber = 0; //---- indicator buffers double Line1Buffer[]; double Line2Buffer[]; double Line3Buffer[]; double Smin[]; double Smax[]; double Trend[]; double Step=0, RevMaxA=0, RevMinA=0; int limit; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- indicator line IndicatorBuffers(6); IndicatorDigits(2);//Digits SetIndexStyle(0,DRAW_LINE,0,2); SetIndexStyle(1,DRAW_LINE,0,1); SetIndexStyle(2,DRAW_LINE,0,1); SetIndexStyle(3,DRAW_NONE,0,1); SetIndexStyle(4,DRAW_NONE,0,1); SetIndexStyle(6,DRAW_NONE); SetIndexBuffer(0,Line1Buffer); SetIndexBuffer(1,Line2Buffer); SetIndexBuffer(2,Line3Buffer); SetIndexBuffer(3,Smin); SetIndexBuffer(4,Smax); SetIndexBuffer(5,Trend); SetIndexShift(0,Z1Advance); SetIndexShift(1,Z1Advance); SetIndexShift(2,Z1Advance); SetIndexShift(3,0); SetIndexShift(4,0); SetIndexShift(5,0); //---- name for DataWindow and indicator subwindow label short_name="Z1Step( "+Z1StepSize/10+", "+Z1StepA/10+","+Z1Advance+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); SetIndexLabel(1,"Z1RevMaxA"); SetIndexLabel(2,"Z1RevMinA"); SetIndexLabel(3,"Z1Smin"); SetIndexLabel(4,"Z1Smax"); SetIndexLabel(5,"Z1Trend"); //---- SetIndexDrawBegin(0,0); SetIndexDrawBegin(1,0); SetIndexDrawBegin(2,0); SetIndexDrawBegin(3,0); SetIndexDrawBegin(4,0); SetIndexDrawBegin(5,0); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Step v1.0 | //+------------------------------------------------------------------+ int start() { int shift, counted_bars=IndicatorCounted(); if ( Z1BarsNumber > 0 ) int Nbars=Z1BarsNumber; else Nbars=Bars; if ( counted_bars > 0 ) limit=Bars-counted_bars; if ( counted_bars < 0 ) return(0); if ( counted_bars ==0 ) limit=Nbars-1; for(shift=limit;shift>=0;shift--) { Step = StepCalcZ1 (Z1HighLow, Z1StepSize, shift); RevMaxA = StepCalcZ1 (Z1HighLow, Z1StepSize, shift) + Z1StepA*Point; RevMinA = StepCalcZ1 (Z1HighLow, Z1StepSize, shift) - Z1StepA*Point; Line1Buffer[shift] = Step; Line2Buffer[shift] = RevMaxA; Line3Buffer[shift] = RevMinA; } return(0); } //---------------------------FIM DO START--------------------- //---- StepCalculation-------------------------------------------------------------------------------------- double StepCalcZ1 (bool HL, double Size, int k) { int counted_bars=IndicatorCounted(); double result; if (HL) { Smax[k]=Low [k]+2.0*Size*Point; Smin[k]=High[k]-2.0*Size*Point; } else { Smax[k]=Close[k]+2.0*Size*Point; Smin[k]=Close[k]-2.0*Size*Point; } if (counted_bars==0) { Smax[limit+1]=Smax[limit]; Smin[limit+1]=Smin[limit]; Trend[limit+1]=0; } Trend[k]=Trend[k+1]; if (High[k]>Smax[k+1]) Trend[k]=1; if (Low [k]0) { if(Smin[k]Smax[k+1]) Smax[k]=Smax[k+1]; result=Smax[k]-Size*Point;//=Low[k]+Size ; } //Print (" k=",k," Trend=",Trend[k], " res=",result," Smax=", Smax[k], " Smin=", Smin[k]); return(result); }