//+------------------------------------------------------------------+ //| made after the idea of MrM | //+------------------------------------------------------------------+ #property link "" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red #property indicator_width1 3 double swings[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { SetIndexBuffer(0,swings); return(0); } int deinit() { return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int limit,counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=MathMin(Bars-counted_bars,Bars-1); // // // find second zigzag point from right (since it can be changed) // // int count = 0; while (count<2 && limit<(Bars-2)) { if (swings[limit] == 0) count++; limit++; } // // // // // for(int i=limit; i>=0; i--) { if (i==(Bars-1)) { swings[i] = 0; continue; } if (iCustom(0,0,"zigzag",12,5,3,0,i)!=0) swings[i] = 0; else swings[i] = swings[i+1]+1; } return(0); }