//+------------------------------------------------------------------+ //| | //| | //+------------------------------------------------------------------+ /* +------------------------------------------------------------------+ +------------------------------------------------------------------+ */ #property indicator_minimum 0.0 #property indicator_maximum 1.5 #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_width1 3 #property indicator_color2 Red #property indicator_width2 3 //---- IndicatorShortName ("PSAR Helper 5M"); IndicatorDigits (0); double CrossUp[]; double CrossDown[]; //int Mode = 1; //extern int TimeFrame = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, 4); SetIndexBuffer(0, CrossUp); SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, 4); SetIndexBuffer(1, CrossDown); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; double MA_1M_Current, MA_1M_Previous, MA_5M_Current,MA_5M_Previous; double MA_Current, MA_Previous; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i = 0; i <= limit; i++) { counter=i; for (counter=i ;counter<=i+9;counter++) // MA_1M_Current = iMA(NULL, PERIOD_M1, 14, 0, MODE_SMA, PRICE_CLOSE, i + 0); // MA_1M_Previous = iMA(NULL, PERIOD_M1, 14, 0, MODE_SMA, PRICE_CLOSE, i + 1); MA_5M_Current = iMA(NULL, PERIOD_M5, 14, 0, MODE_SMA, PRICE_CLOSE, i + 0); MA_5M_Previous = iMA(NULL, PERIOD_M5, 14, 0, MODE_SMA, PRICE_CLOSE, i + 1); if ( iClose(NULL,PERIOD_M5,i) > iSAR(NULL, PERIOD_M5,0.04,0.05, i) && MA_5M_Current > MA_5M_Previous && iClose(NULL,PERIOD_M5,i) > MA_5M_Previous && iOpen(NULL,PERIOD_M5,i) > MA_5M_Previous ) { CrossUp[i] = 1; } else if ( iClose(NULL,PERIOD_M5,i) < iSAR(NULL, PERIOD_M5,0.04,0.05, i) && MA_5M_Current < MA_5M_Previous && iClose(NULL,PERIOD_M5,i) < MA_5M_Previous && iOpen(NULL,PERIOD_M5,i) < MA_5M_Previous ) { CrossDown[i] = 1; } } return(0); }