
//---- indicator settings
#property  indicator_separate_window

#property  indicator_levelstyle STYLE_DASH
#property  indicator_levelcolor Black

#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_color3  Lime

#property  indicator_width1  1
#property  indicator_width2  2
#property  indicator_width3  2

#property  indicator_buffers 5

//---- indicator parameters
extern int period=60;   
extern int method=1;    // 0(sma),1(ema),2(smth),3(lnrwgt)
extern int applied=5;   // 0(close),1(open),2(high),3(low),4(median),5(typical),6(weighted)
extern int SignalSMA1=3;
extern int SignalSMA2=20;
//---- indicator buffers
double MaBuffer[];
double SignalBuffer1[];
double SignalBuffer2[];
double longarrows[];
double shortarrows[];

int indention = 8;
double Pnt;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_ARROW,EMPTY,1,Lime);
   SetIndexStyle(4,DRAW_ARROW,EMPTY,1,DarkOrange);
   
   SetIndexArrow(3,228);
   SetIndexArrow(4,230);   
   
   SetIndexDrawBegin(1,SignalSMA1);
   SetIndexDrawBegin(1,SignalSMA2);
   IndicatorDigits(Digits+1);
   
//---- indicator buffers mapping
   SetIndexBuffer(0,MaBuffer);
   SetIndexBuffer(1,SignalBuffer1);
   SetIndexBuffer(2,SignalBuffer2);
   SetIndexBuffer(3,longarrows);
   SetIndexBuffer(4,shortarrows);
    
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("MA("+period+","+method+","+applied+","+SignalSMA1+","+SignalSMA2+")");
   SetIndexLabel(0,"MA");
   SetIndexLabel(1,"Signal1");
   SetIndexLabel(2,"Signal2");
   
    Pnt = Point;
    if (Digits == 5)
        Pnt = 0.0001;
    if (Digits == 3)
        Pnt = 0.01;

//---- initialization done
   return(0);
  }


int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(int i=0; i<limit; i++)
      MaBuffer[i]=(iMA(NULL,0,period,0,method,applied,i)-iMA(NULL,0,period,0,method,applied,i+1))/Pnt*10;

   for(i=0; i<limit; i++)
      SignalBuffer1[i]=iMAOnArray(MaBuffer,Bars,SignalSMA1,0,MODE_SMA,i);

   for(i=0; i<limit; i++)
      SignalBuffer2[i]=iMAOnArray(MaBuffer,Bars,SignalSMA2,0,MODE_SMA,i);
   
   
   //#######################################################################################################  
   //#######################################################################################################
   
   //EVERYTHING UP TO THIS POINT WORKS FINE BUT THE NEXT 6 LINES DON'T GIVE ME ANY ARROWS?? THX FOR LOOKING.
   
   //#######################################################################################################
   //#######################################################################################################
   
   longarrows[i+1] = EMPTY_VALUE;
   shortarrows[i+1] = EMPTY_VALUE;
      if(SignalBuffer2[i+1]>SignalBuffer1[i+1])
        longarrows[i+1] = High[i+1] + indention*Pnt;
      if(SignalBuffer2[i]>SignalBuffer1[i])
        shortarrows[i+1] = Low[i+1] - indention*Pnt;
   
   
   
   
//---- done
   return(0);
  }
//+------------------------------------------------------------------+