#property strict #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Yellow #property indicator_color2 Blue int trend = 0; double Up[], Dn[]; double max,min; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //--- indicator buffers mapping SetIndexBuffer(0,Up); SetIndexStyle (0,DRAW_LINE,0,1); SetIndexBuffer(1,Dn); SetIndexStyle (1,DRAW_LINE,0,1); SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); //--- return(0); } int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //--- int Counted_bars=IndicatorCounted(); int i=Bars-Counted_bars-1; if (i>1000-1) i=1000-1; while(i>=0) { max = iHigh(NULL, 0, iHighest(NULL,0,MODE_HIGH,30,i+1)); min = iLow(NULL, 0, iLowest( NULL,0,MODE_LOW, 30,i+1)); if( iMA(NULL,0,15,0,MODE_EMA,PRICE_CLOSE,i) > iMA(NULL,0,80,0,MODE_EMA,PRICE_CLOSE,i) ) { trend = 1; } if( iMA(NULL,0,15,0,MODE_EMA,PRICE_CLOSE,i) < iMA(NULL,0,80,0,MODE_EMA,PRICE_CLOSE,i) ) { trend = 2; } if(trend==1) { Up[i]=min; if(Up[i]Dn[i+1]) { Dn[i]=Dn[i+1]; } } i--; } return(0); }