//+------------------------------------------------------------------+
//| boxingislife.mq4.mq4
//| Rob Rice (blueruby)
//| http://www.forexfactory.com/showthread.php?t=13321&highlight=boxingislife
//+------------------------------------------------------------------+

#property copyright "Rob Rice (blueruby)"
#property link      "http://www.forexfactory.com/showthread.php?t=13321&highlight=boxingislife"

#property indicator_chart_window

datetime lastbar;
extern bool EmailAlert;
extern bool SoundON = True;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

   Comment ("boxingislife signal indicator ON");

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
   Comment ("");
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   
   double base_20 = iStochastic(NULL,0,20,10,20,MODE_SMA,0,0,0);
   double signal_20 = iStochastic(NULL,0,20,10,20,MODE_SMA,0,1,0);
   
   double base_50 = iStochastic(NULL,0,50,10,20,MODE_SMA,0,0,0);
   double signal_50 = iStochastic(NULL,0,50,10,20,MODE_SMA,0,1,0);

   double base_5 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,0,0);
   double signal_5 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,1,0);

   datetime curbar = Time[0];
   if (lastbar != curbar)
      {
      lastbar = curbar;
      if ((base_20 < signal_20) && (base_50 < signal_50) && (base_5 > 60))
         {
         Alert ("boxingislife short setup on ",Symbol()," ",Period()," min");
         SendMail("boxingislife","Short setup on " + (StringConcatenate(Symbol()," ",Period())));
         if (SoundON == true) PlaySound ("alert2.wav");
         }
      
      if ((base_20 > signal_20) && (base_50 > signal_50) && (base_5 < 40))
         {
         Alert ("boxingislife long setup on ",Symbol()," ",Period()," min");
         SendMail("boxingislife","Short setup on " + (StringConcatenate(Symbol()," ",Period())));
         if (SoundON == true) PlaySound ("alert2.wav");
         }  
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+