//+------------------------------------------------------------------+
//|                                         ZeroLag TPHA Pointer.mq4 |
//|                                                          Kalenzo |
//|                                          http://www.fxservice.eu |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "http://www.fxservice.eu"
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Magenta
#property indicator_width1 3
#property indicator_width2 3

extern int iPeriod1 = 144;
extern int iPeriod2 = 21;
double u[],d[];

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
SetIndexBuffer(0,u);
SetIndexBuffer(1,d);

SetIndexLabel(0,"UP SIGNAL");
SetIndexLabel(1,"DN SIGNAL");

SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0, SYMBOL_ARROWUP);

SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1, SYMBOL_ARROWDOWN);

SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
   for(int i=0; i<limit; i++)
   {
      u[i] = 0.0;
      d[i] = 0.0;
      double cmv1 = iCustom(NULL,0,"ZeroLag_tpTEMA",iPeriod1,0,i);
      double cmv2 = iCustom(NULL,0,"ZeroLag_haTEMA",iPeriod2,0,i);
      double pmv1 = iCustom(NULL,0,"ZeroLag_tpTEMA",iPeriod1,0,i+1);
      double pmv2 = iCustom(NULL,0,"ZeroLag_haTEMA",iPeriod2,0,i+1);
      
      
      if(cmv1<cmv2 && pmv1>=pmv2) 
      {
         u[i] = Low[i]-10*Point;
      }
      
      if(cmv1>cmv2 && pmv1<=pmv2) 
      {
         d[i] = High[i]+10*Point;
      }
   }
   return(0);
  }
//+------------------------------------------------------------------+