//+------------------------------------------------------------------+ //| alb - swing points.mq4 | //+------------------------------------------------------------------+ #property copyright "mladen" #property link "mladenfx@gmail.com" #property indicator_separate_window #property indicator_minimum -1 #property indicator_maximum 1 #property indicator_buffers 1 #property indicator_color1 Red double swingBuffer[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int init() { SetIndexBuffer(0,swingBuffer); return(0); } int deinit() { return(0); } // // // // // int start() { int counted_bars=IndicatorCounted(); int i,limit; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit = Bars-counted_bars; for(i=limit; i>=0; i--) { int swing = 0; if (High[i]>High[i+1] && High[i+1]>High[i+2] && Low[i+2] < Low[i+3] && Low[i+3] < Low[i+4]) swing = -1; if (Low[i] < Low[i+1] && Low[i+1] < Low[i+2] && High[i+2]>High[i+3] && High[i+3]>High[i+4]) swing = 1; swingBuffer[i] = swing; } return(0); }