//+------------------------------------------------------------------+
//|                                              ��������� Sidus_Bago|
//| ��������� ����������� �������� method � price MA
//| ������ ����� ���������� ����� http://bluedream.ucoz.ru/faq
//+------------------------------------------------------------------+
#define FIRST_NAME "Sidus_Bago"  // ��� �����������
#define SURNAME "indicator"
#define VER "V1"                                     
#define RELIZE "GS_2011_03_14"                        
#define AUTOR "� valenok2003@mail.ru"

string   Name_Window,
         Name_Obj_Advert = "Advert";
int TF;
string Txt_TF;
//+------------------------------------------------------------------+
//|                                   Sidus_Bago Entry Indicator.mq4 |
//|                                                              AHA |
//|          Ideas by Sidus, Bagovino, OrangeRoshan, and many others |
//|                                                                  |
//|             ��������� ��������� � �������� ������ Sergey Gulyaev |
//|                         ICQ 365919666. mail: valenok2003@mail.ru |
//+------------------------------------------------------------------+
#property copyright "modify valenok2003@mail.ru"
#property link      "http://bluedream.ucoz.ru/"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_color4 Red

//---- input parameters
extern int  Period_MA_Fast = 5;
extern int  Mode_MA_Fast = 0;
extern int  Price_MA_Fast = 0;
extern int  Period_MA_Slow = 12;
extern int  Mode_MA_Slow = 0;
extern int  Price_MA_Slow = 0;
extern int  Period_RSI     = 14;
extern int  Top_Level_RSI  = 46;
extern int  Boot_Level_RSI = 54;
extern bool Alert_ON = true;

double Dif_MA=0,
       Entry_Point = 0;

bool   FLAG_POINT_DOWN = true,
       FLAG_POINT_UP   = true;

//---- buffers
double MA_Fast[];
double MA_Slow[];
double Pointer_UP[];
double Pointer_DOWN[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{  
//----
   Txt_TF = txt_tf(Period());
//---- indicators ----------------------------------------------------
   SetIndexBuffer(0,MA_Fast);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexLabel (0,"MA_Fast " + DoubleToStr(Period_MA_Fast,0));
   
   SetIndexBuffer(1,MA_Slow);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexLabel (1,"MA_Slow " + DoubleToStr(Period_MA_Slow,0));
 
   SetIndexBuffer(2,Pointer_UP);
   SetIndexStyle(2,DRAW_ARROW,0,3);
   SetIndexArrow(2,241); //217
   SetIndexEmptyValue(2,0.0);
 
   SetIndexBuffer(3,Pointer_DOWN);
   SetIndexStyle(3,DRAW_ARROW,0,3);
   SetIndexArrow(3,242); //218
   SetIndexEmptyValue(3,0.0);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//----
   Comment("");
   ObjectDelete("Advert");
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
//----
   double RSI_Value_0,
          RSI_Value_1,
          Max,
          Min;
   int i, n,                        // ������ ����
       Counted_bars,                // ���������� ������������ ����� 
       cnt;
//--------------------------------------------------------------------
   Counted_bars = IndicatorCounted(); // ���������� ������������ ����� 
   i = Bars-Counted_bars-1;           // ������ ������� ��������������
   while(i >= 0)                      // ���� �� ������������� �����
   {  MA_Fast[i]  = iMA(NULL, 0, Period_MA_Fast, 0, Mode_MA_Fast,Price_MA_Fast, i);
      MA_Slow[i]  = iMA(NULL, 0, Period_MA_Slow, 0, Mode_MA_Slow,Price_MA_Slow, i);
      RSI_Value_0 = iRSI(NULL,0, Period_RSI, PRICE_OPEN, i);
      RSI_Value_1 = iRSI(NULL,0, Period_RSI, PRICE_OPEN, i+1);
     
      Dif_MA = (MA_Fast[i] - MA_Slow[i])/Point;
      Comment(FIRST_NAME + ": " + "MA_Fast - MA_Slow = " + DoubleToStr(Dif_MA, 0) + " points");
      Entry_Point = 0;
//--------------------------------------------------------------------
//-- ������ ���� -----------------------------------------------------     
      if(Dif_MA < 0 && RSI_Value_0 < Boot_Level_RSI && RSI_Value_1 > RSI_Value_0 && FLAG_POINT_DOWN) 
      {  // ���� ������� ��� ���������������� �������
         Max = 0; 
         for(n = i; n < i + 10; n++)   if(High[n] > Max) Max = High[n];
//---------------------------
         Pointer_DOWN[i] = Max;
         if(i == 0)
         {  Entry_Point = Bid;
            if(Alert_ON == true) Alert(FIRST_NAME + ": " + Symbol() + " " + Txt_TF + "  ����������. ����� �����: " + DoubleToStr(Entry_Point, Digits));        
            else PlaySound("expert.wav");
         }
         FLAG_POINT_DOWN = false;
         FLAG_POINT_UP = true;
      }
//--------------------------------------------------------------------
//-- ������ ����� ----------------------------------------------------
      if(Dif_MA > 0 && RSI_Value_0 > Top_Level_RSI && RSI_Value_1 < RSI_Value_0 && FLAG_POINT_UP) 
      {  // ���� ������� ��� ���������������� �������
         Min = 100000; 
         for(n = i; n < i + 10; n++)   if(Low[n] < Min) Min = Low[n];
//---------------------------
         Pointer_UP[i] = Min;
         if(i == 0)
         {  Entry_Point = Ask;
            if(Alert_ON == true) Alert(FIRST_NAME + ": " + Symbol() + " " + Txt_TF + "  ���������. ����� �����: " + DoubleToStr(Entry_Point, Digits));        
            else PlaySound("expert.wav");
         }
         FLAG_POINT_DOWN = true;
         FLAG_POINT_UP = false;
     }
//--------------------------------------------------------------------
     i--;
   }
//----
   output_ADVERT();
   return(0);
}
//+------------------------------------------------------------------+
//                             �������
//+------------------------------------------------------------------+
//+-------
//+-------
//+------------------------------------------------------------------+
//| ������� �������� �� � ��������� ������  
//+------------------------------------------------------------------+
string txt_tf(int _TF)
{  
   string _Txt_TF;
   switch(_TF)
   {
      case PERIOD_M1:  _Txt_TF = "M1";  break;
      case PERIOD_M5:  _Txt_TF = "M5";  break;
      case PERIOD_M15: _Txt_TF = "M15"; break;
      case PERIOD_M30: _Txt_TF = "M30"; break;
      case PERIOD_H1:  _Txt_TF = "H1";  break;
      case PERIOD_H4:  _Txt_TF = "H4";  break;
      case PERIOD_D1:  _Txt_TF = "D1";  break;
      case PERIOD_W1:  _Txt_TF = "W1";  break;
      case PERIOD_MN1: _Txt_TF = "MN1"; break;
   }
   return(_Txt_TF);
}
//+------------------------------------------------------------------+
//+-------
//+-------
//+-------------------------------------------------------------------
//| output ADVERT                                          2011_04_13
//+------------------------------------------------------------------+
int
   _Cnt_Advert = 0,
   _Time_Start_Advert = 0;
string 
   _Txt_Advert,   
   _AUTOR = "tradelikeapro.ru",
   _URL = "tradelikeapro.ru",
   _ADVERT = "tradelikeapro.ru",
   _ADVERT2 = "tradelikeapro.ru";
void output_ADVERT()
{  int 
      _Time_Chenge_Advert = 30;
   if(TimeCurrent() > _Time_Start_Advert + _Time_Chenge_Advert)
   {  switch(_Cnt_Advert)
      {  case 0:
            _Txt_Advert = _ADVERT; 
            _Time_Start_Advert = TimeCurrent();
            _Cnt_Advert = 1;
         break;
         case 1:
            _Txt_Advert = _URL; 
            _Time_Start_Advert = TimeCurrent();
            _Cnt_Advert = 2;
         break;
         case 2:
            _Txt_Advert = _AUTOR; 
            _Time_Start_Advert = TimeCurrent();
            _Cnt_Advert = 3;
         break;
         case 3:
            _Txt_Advert = _ADVERT2; 
            _Time_Start_Advert = TimeCurrent();
            _Cnt_Advert = 0;
         break;
      }
   }
   ObjectCreate ("Advert", OBJ_LABEL, 0, 0, 0);
   ObjectSet    ("Advert", OBJPROP_CORNER, 2);
   ObjectSet    ("Advert", OBJPROP_XDISTANCE, 5);
   ObjectSet    ("Advert", OBJPROP_YDISTANCE, 5);
   ObjectSetText("Advert", _Txt_Advert, 10, "Arial", LimeGreen);
   return;
}
//+-------------------------------------------------------------------
//+-------