//+------------------------------------------------------------------+
//|                                                    HMA Cross.mq4 |
//|                         Revamped and Formatted For HMA By BLUR71 |
//|                   Original Code By Kalenzo, Modded By Newdigital |
//+------------------------------------------------------------------+
#property copyright "BLUR71"
#property link      "blrobertsjr@hotmail.com"
#property link      "www.forex-tsd.com"  
#property indicator_chart_window
#property indicator_color1 Aqua
#property indicator_color2 Magenta
#property indicator_width1 3
#property indicator_width2 3
#property indicator_buffers 2
extern string RSXFile   = "3c_Turbo_JRSX_Filtered";
extern double RSXLen1    =  5,
              RSXFilter1 =  0,
              RSXLen2    =  70,
              RSXFilter2 =  0;
extern string AlertFile  = "Alert.wav";
extern bool   AlertCross = true,
              AlertSound = false,
              AlertInfo  = false,
              DataSelect = false;
//----
double UpBuffer[],
       DnBuffer[],
       alertBar;
//----
int init()
  {SetIndexStyle(0,DRAW_ARROW,EMPTY);
   SetIndexStyle(1,DRAW_ARROW,EMPTY);
   SetIndexBuffer(0,UpBuffer);
   SetIndexBuffer(1,DnBuffer);
   SetIndexArrow(0,241);
   SetIndexArrow(1,242);
   SetIndexLabel(0,"Turbo Up");
   SetIndexLabel(1,"Turbo Down");
   if(DataSelect==false)
   SetIndexLabel(0,NULL);
   SetIndexLabel(1,NULL);
   return(0);}
//----
int deinit()
 { return(0); }
//----
int start()
  {int limit,
       counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i = 0 ;i < limit ;i++)
     {double PrevRSX1 = iCustom(NULL,0,RSXFile,RSXLen1,RSXFilter1,0,i+1),
             CurrRSX1 = iCustom(NULL,0,RSXFile,RSXLen1,RSXFilter1,0,i),
             PrevRSX2 = iCustom(NULL,0,RSXFile,RSXLen2,RSXFilter2,0,i+1),
             CurrRSX2 = iCustom(NULL,0,RSXFile,RSXLen2,RSXFilter2,0,i);
//----
     if( CurrRSX1 > CurrRSX2 && PrevRSX1 <= PrevRSX2)
      {UpBuffer[i] = iLow(Symbol(),0,i)-(3*Point);
       DnBuffer[i] = EMPTY_VALUE;
      if (AlertSound==1) PlaySound(AlertFile);
      if (AlertCross==1 && Bars>alertBar) {Alert(Symbol(),Period()," RSX "+DoubleToStr(RSXLen1,0)+" x "+
                                           DoubleToStr(RSXLen2,0)+" Buy");alertBar = Bars;}
      if (AlertInfo==1) Comment (" RSX X Buy @ Ask:",Ask,", Bid:",Bid,", ",TimeToStr(CurTime(),TIME_DATE)," ",
                        TimeHour(CurTime()),":",TimeMinute(CurTime()),", ",Symbol()," ",Period());}
      else if( PrevRSX1 >= PrevRSX2 && CurrRSX1 < CurrRSX2)
      {UpBuffer[i] = EMPTY_VALUE;
       DnBuffer[i] = iHigh(Symbol(),0,i)+(3*Point);
      if (AlertSound==1) PlaySound(AlertFile);
      if (AlertCross==1 && Bars>alertBar) {Alert(Symbol(),Period()," RSX "+DoubleToStr(RSXLen1,0)+" x "+
                                           DoubleToStr(RSXLen2,0)+" Sell");alertBar = Bars;} 
      if (AlertInfo==1) Comment (" RSX X Sell @ Ask:",Ask,", Bid:",Bid,", ",TimeToStr(CurTime(),TIME_DATE)," ",
                                  TimeHour(CurTime()),":",TimeMinute(CurTime()),", ",Symbol()," ",Period());}
      else
      {DnBuffer[i] = EMPTY_VALUE;
       UpBuffer[i] = EMPTY_VALUE;}}
//----
  return(0);}
//----