#property copyright "Copyright © 2009, MaGooLaboratory" #property link "http://xxx.com.br" #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Yellow #property indicator_color2 Teal #property indicator_color3 Teal #property indicator_color4 White //---- input parameters extern int StepSize = 6000; extern int Advance = 0; //---- indicator buffers double Line1Buffer[]; double Smax[]; double Smin[]; double Trend[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- indicator line IndicatorBuffers(4); IndicatorDigits(2);//Digits SetIndexStyle(0,DRAW_LINE,0,2); SetIndexStyle(1,DRAW_NONE,2,1); SetIndexStyle(2,DRAW_NONE,2,1); SetIndexStyle(3,DRAW_NONE); SetIndexBuffer(0,Line1Buffer); SetIndexBuffer(1,Smax); SetIndexBuffer(2,Smin); SetIndexBuffer(3,Trend); SetIndexShift(0,Advance); SetIndexShift(1,0); SetIndexShift(2,0); SetIndexShift(3,0); //---- name for DataWindow and indicator subwindow label short_name="Step ("+StepSize/10+")"; IndicatorShortName(short_name); SetIndexLabel(0,"StepMa"); SetIndexLabel(1,"Smax"); SetIndexLabel(2,"Smin"); SetIndexLabel(3,"Trend"); //---- SetIndexDrawBegin(0,0); SetIndexDrawBegin(1,0); SetIndexDrawBegin(2,0); SetIndexDrawBegin(3,0); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| StepCalc Function | //+------------------------------------------------------------------+ int start() { int i; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- the last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; //---- main loop for( i=limit; i>=0; i-- ) { Smax[i]=Low [i]+2.0*StepSize*Point; Smin[i]=High[i]-2.0*StepSize*Point; Trend[i]=Trend[i+1]; if (Low [i]Smax[i+1]) Trend[i]=1; if(Trend[i]<0) { if(Smax[i]>Smax[i+1]) Smax[i]=Smax[i+1]; Line1Buffer[i] = Smax[i] - StepSize*Point; } if(Trend[i]>0) { if(Smin[i]