//+------------------------------------------------------------------+
//|                                                      signals.mq4 |
//|                                     Copyright © 2005, Nick Bilak |
//|                                       http://www.forex-tsd.com / |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Nick Bilak"
#property link      "http://metatrader.50webs.com/"

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

//---- buffers
double buy[];
double sell[];

extern int    T3Period  = 14;
extern int    T3Price   = PRICE_CLOSE;
extern double b         = 1.00;
extern int    Fast      = 5;
extern int    Slow      = 20;
extern int    SigShift  = 1;
int last;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   
//---- drawing settings
   SetIndexBuffer(0,buy);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,233);
   SetIndexEmptyValue(0,0);
   SetIndexBuffer(1,sell);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexEmptyValue(1,0);
   SetIndexArrow(1,234);

//---- initialization done
   return(0);
  }

int start() {


   int shift,limit;
   int counted_bars=IndicatorCounted();
   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
   limit=Bars-Slow-1;
   if(counted_bars>=Slow+1) limit=Bars-counted_bars-1;
 	
 	double emaf11,emaf12,emas21,emas22,t3;
 	
   for(shift = limit; shift >= 0; shift--) {
      t3=iCustom(NULL,0,"T3_clean",T3Period,T3Price,b,0,shift+SigShift);
      emaf11=iMA(NULL,0,Fast,0,MODE_EMA,PRICE_CLOSE,shift+SigShift);
      emaf12=iMA(NULL,0,Fast,0,MODE_EMA,PRICE_CLOSE,shift+1+SigShift);
      emas21=iMA(NULL,0,Slow,0,MODE_EMA,PRICE_OPEN,shift+SigShift);
      emas22=iMA(NULL,0,Slow,0,MODE_EMA,PRICE_OPEN,shift+1+SigShift);
   	
      if (emaf11>emas21 && emaf12<=emas22 && emaf11>t3) {
         buy[shift]=Low[shift]-iATR(NULL,0,20,shift)/2.0;
      }
      if (emaf11<emas21 && emaf12>=emas22 && emaf11<t3) {
         sell[shift]=High[shift]+iATR(NULL,0,20,shift)/2.0;
      }
   }
    
   return(0);
}
//+------------------------------------------------------------------+



