//+------------------------------------------------------------------+
//|                                       PivotSR.mq4, version 1.001 |
//|                           Copyright © 2009, J.Katvickis aka KAJA |
//|                                       JurijusKatvickis@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, J.Katvickis aka KAJA"
#property link      "JurijusKatvickis@gmail.com"

#property indicator_chart_window

extern bool Floor_Pivot     = true;
extern bool DeMark_Pivot    = false;
extern bool Woodie_Pivot    = false;
extern bool Camarilla_Pivot = false;
extern int  delta_Time      = 720;
//   extern bool Sound_Alert_Red=true,Sound_Alert_Blue=true,PopupON=false;
//   extern bool EmailON=false;
//   string AlertSound="alert.wav";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
      ObjectDelete("Label");
      if ( Floor_Pivot )
      {
         ObjectDelete("R3");        ObjectDelete("R2");        ObjectDelete("R1");
         ObjectDelete("Label_R3");  ObjectDelete("Label_R2");  ObjectDelete("Label_R1");
         ObjectDelete("Pivot");
         ObjectDelete("Label_Pivot");
         ObjectDelete("S1");        ObjectDelete("S2");        ObjectDelete("S3");
         ObjectDelete("Label_S1");  ObjectDelete("Label_S2");  ObjectDelete("Label_S3");
      }  
      else if ( DeMark_Pivot )
      {
         ObjectDelete("R1");
         ObjectDelete("Label_R1");
         ObjectDelete("S1");
         ObjectDelete("Label_S1");
      }   
      else if ( Woodie_Pivot )
      {
         ObjectDelete("R2");        ObjectDelete("R1");
         ObjectDelete("Label_R2");  ObjectDelete("Label_R1");
         ObjectDelete("Pivot");
         ObjectDelete("Label_Pivot");
         ObjectDelete("S1");        ObjectDelete("S2");
         ObjectDelete("Label_S1");  ObjectDelete("Label_S2");
      }   
      else if ( Camarilla_Pivot )
      {
         ObjectDelete("R4");        ObjectDelete("R3");        ObjectDelete("R2");        ObjectDelete("R1");
         ObjectDelete("Label_R4");  ObjectDelete("Label_R3");  ObjectDelete("Label_R2");  ObjectDelete("Label_R1");
         ObjectDelete("Pivot");
         ObjectDelete("Label_Pivot");
         ObjectDelete("S1");        ObjectDelete("S2");        ObjectDelete("S3");        ObjectDelete("S4");
         ObjectDelete("Label_S1");  ObjectDelete("Label_S2");  ObjectDelete("Label_S3");  ObjectDelete("Label_S4");
      }   
   return;
  }
//+------------------------------------------------------------------+
//| Main function                                                    |
//+------------------------------------------------------------------+
int start()
  {
 //+-----------------------------------------------------------------------------------------------  
      int      CYear, CMonth, CDay, CHour, CMinute;
      int      CTime;
      int      XX, YY, dYY;
      double   CHigh, CLow, CClose, NOpen; 
      double   Pivot, R1, R2, R3, R4, S1, S2, S3, S4;
      double   Price;
      double   iLabel; 
      string   sLabel;
      color    R_Color, Pivot_Color, S_Color;
      
//+------------------------------------------------------------------+
//| Time frame calculate                                             |
//+------------------------------------------------------------------+
      CYear   = TimeYear   ( Time[0] );
      CMonth  = TimeMonth  ( Time[0] );
      CDay    = TimeDay    ( Time[0] );
      CHour   = TimeHour   ( Time[0] );
      CMinute = TimeMinute ( Time[0] );
      
      if ( Period () < PERIOD_H1 )
      {
         CTime  = MathFloor ( ( CHour * 60 + CMinute + delta_Time ) / Period () );
         CHigh  = iHigh  ( NULL, PERIOD_D1, 1 );
         CLow   = iLow   ( NULL, PERIOD_D1, 1 );
         CClose = iClose ( NULL, PERIOD_D1, 1 );
         NOpen  = iOpen  ( NULL, PERIOD_D1, 0 );
      }
      else
         CTime = CHour;
//+------------------------------------------------------------------+
//| Init condition, text position, current price and colors                                                    |
//+------------------------------------------------------------------+
      XX = 10;
      YY = 10;
      dYY = 12;
      Price = ( Ask + Bid ) / 2;
      R_Color = DeepSkyBlue;
      Pivot_Color = Yellow;
      S_Color = Red;
//+------------------------------------------------------------------+
//| Floor pivot points                                               |
//+------------------------------------------------------------------+
      if ( Floor_Pivot )
      {
         Pivot = ( CHigh + CLow + CClose ) / 3;
         R1    = ( 2 * Pivot ) - CLow;
         R2    = Pivot + CHigh - CLow;
         R3    = CHigh + 2 * ( Pivot - CLow );
         S1    = ( 2 * Pivot ) - CHigh;  
         S2    = Pivot - CHigh + CLow;
         S3    = CLow - 2 * ( CHigh - Pivot );

         ObjectCreate ( "Label", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label", "Floor pivot points:", 8, "Courier New", White );

         YY += dYY;
         ObjectCreate ( "R3", OBJ_TREND, 0, Time [CTime], R3, Time[0]+10, R3 );
         ObjectSet ( "R3", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R3 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R3=", R3, "    dR3=", iLabel );
         ObjectCreate ( "Label_R3", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R3", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R3", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R3", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R3", sLabel, 8, "Courier New", R_Color );
         
         YY += dYY;
         ObjectCreate ( "R2", OBJ_TREND, 0, Time [CTime], R2, Time[0]+10, R2 );
         ObjectSet ( "R2", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R2 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R2=", R2, "    dR2=", iLabel );
         ObjectCreate ( "Label_R2", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R2", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R2", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R2", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R2", sLabel, 8, "Courier New", R_Color );

         YY += dYY;
         ObjectCreate ( "R1", OBJ_TREND, 0, Time [CTime], R1, Time[0]+10, R1 );
         ObjectSet ( "R1", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R1 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R1=", R1, "    dR1=", iLabel );
         ObjectCreate ( "Label_R1", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R1", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R1", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R1", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R1", sLabel, 8, "Courier New", R_Color );

         YY += dYY;
         ObjectCreate ( "Pivot", OBJ_TREND, 0, Time [CTime], Pivot, Time[0]+10, Pivot );
         ObjectSet ( "Pivot", OBJPROP_COLOR, Pivot_Color );
         iLabel = MathFloor ( ( Pivot - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "Pivot=", Pivot, " dPivot=", iLabel );
         ObjectCreate ( "Label_Pivot", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_Pivot", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_Pivot", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_Pivot", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_Pivot", sLabel, 8, "Courier New", Pivot_Color );

         YY += dYY;
         ObjectCreate ( "S1", OBJ_TREND, 0, Time [CTime], S1, Time[0]+10, S1 );
         ObjectSet ( "S1", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S1 ) * 10000 ); 
         sLabel = StringConcatenate ( "S1=", S1, "    dS1=", iLabel );
         ObjectCreate ( "Label_S1", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S1", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S1", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S1", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S1", sLabel, 8, "Courier New", S_Color );

         YY += dYY;
         ObjectCreate ( "S2", OBJ_TREND, 0, Time [CTime], S2, Time[0]+10, S2 );
         ObjectSet ( "S2", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S2 ) * 10000 ); 
         sLabel = StringConcatenate ( "S2=", S2, "    dS2=", iLabel );
         ObjectCreate ( "Label_S2", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S2", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S2", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S2", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S2", sLabel, 8, "Courier New", S_Color );

         YY += dYY;
         ObjectCreate ( "S3", OBJ_TREND, 0, Time [CTime], S3, Time[0]+10, S3 );
         ObjectSet ( "S3", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S3 ) * 10000 ); 
         sLabel = StringConcatenate ( "S3=", S3, "    dS3=", iLabel );
         ObjectCreate ( "Label_S3", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S3", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S3", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S3", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S3", sLabel, 8, "Courier New", S_Color );
      }
//+------------------------------------------------------------------+
//| Tom DeMark's pivot points                                               |
//+------------------------------------------------------------------+
      else if ( DeMark_Pivot )
      {
         if ( CClose < NOpen )
            Pivot = CHigh + 2 * CLow + CClose;
         if ( CClose > NOpen )
            Pivot = 2* CHigh + CLow + CClose;
         if ( CClose > NOpen )
            Pivot = CHigh + CLow + 2* CClose;
         R1    = Pivot / 2 - CLow;
         S1    = Pivot / 2 - CHigh;  

         ObjectCreate ( "Label", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label", "Tom DeMarks pivot points:", 8, "Courier New", White );

         YY += dYY;
         ObjectCreate ( "R1", OBJ_TREND, 0, Time [CTime], R1, Time[0]+10, R1 );
         ObjectSet ( "R1", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R1 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R1=", R1, "    dR1=", iLabel );
         ObjectCreate ( "Label_R1", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R1", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R1", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R1", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R1", sLabel, 8, "Courier New", R_Color );

         YY += dYY;
         ObjectCreate ( "S1", OBJ_TREND, 0, Time [CTime], S1, Time[0]+10, S1 );
         ObjectSet ( "S1", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S1 ) * 10000 ); 
         sLabel = StringConcatenate ( "S1=", S1, "    dS1=", iLabel );
         ObjectCreate ( "Label_S1", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S1", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S1", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S1", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S1", sLabel, 8, "Courier New", S_Color );
      }         
//+------------------------------------------------------------------+
//| Woodie's pivot points                                               |
//+------------------------------------------------------------------+
      else if ( Woodie_Pivot )
      {
         Pivot = ( CHigh + CLow + 2* CClose ) / 4;
         R1    = ( 2 * Pivot ) - CLow;
         R2    = Pivot + CHigh - CLow;
         S1    = ( 2 * Pivot ) - CHigh; 
         S2    = Pivot - CHigh + CLow;

         ObjectCreate ( "Label", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label", "Woodies pivot points:", 8, "Courier New", White );
         
         YY += dYY;
         ObjectCreate ( "R2", OBJ_TREND, 0, Time [CTime], R2, Time[0]+10, R2 );
         ObjectSet ( "R2", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R2 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R2=", R2, "    dR2=", iLabel );
         ObjectCreate ( "Label_R2", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R2", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R2", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R2", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R2", sLabel, 8, "Courier New", R_Color );

         YY += dYY;
         ObjectCreate ( "R1", OBJ_TREND, 0, Time [CTime], R1, Time[0]+10, R1 );
         ObjectSet ( "R1", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R1 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R1=", R1, "    dR1=", iLabel );
         ObjectCreate ( "Label_R1", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R1", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R1", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R1", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R1", sLabel, 8, "Courier New", R_Color );

         YY += dYY;
         ObjectCreate ( "Pivot", OBJ_TREND, 0, Time [CTime], Pivot, Time[0]+10, Pivot );
         ObjectSet ( "Pivot", OBJPROP_COLOR, Pivot_Color );
         iLabel = MathFloor ( ( Pivot - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "Pivot=", Pivot, " dPivot=", iLabel );
         ObjectCreate ( "Label_Pivot", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_Pivot", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_Pivot", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_Pivot", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_Pivot", sLabel, 8, "Courier New", Pivot_Color );

         YY += dYY;
         ObjectCreate ( "S1", OBJ_TREND, 0, Time [CTime], S1, Time[0]+10, S1 );
         ObjectSet ( "S1", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S1 ) * 10000 ); 
         sLabel = StringConcatenate ( "S1=", S1, "    dS1=", iLabel );
         ObjectCreate ( "Label_S1", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S1", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S1", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S1", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S1", sLabel, 8, "Courier New", S_Color );

         YY += dYY;
         ObjectCreate ( "S2", OBJ_TREND, 0, Time [CTime], S2, Time[0]+10, S2 );
         ObjectSet ( "S2", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S2 ) * 10000 ); 
         sLabel = StringConcatenate ( "S2=", S2, "    dS2=", iLabel );
         ObjectCreate ( "Label_S2", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S2", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S2", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S2", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S2", sLabel, 8, "Courier New", S_Color );
      }         
//+------------------------------------------------------------------+
//| Camarilla pivot points                                               |
//+------------------------------------------------------------------+
      else if ( Camarilla_Pivot )
      {
         R4    = ( CHigh - CLow ) * 1.1 / 2 + CClose;
         R3    = ( CHigh - CLow ) * 1.1 / 4 + CClose;
         R2    = ( CHigh - CLow ) * 1.1 / 6 + CClose;
         R1    = ( CHigh - CLow ) * 1.1 /12 + CClose;
         S1    = CClose - ( CHigh - CLow ) * 1.1 /12;
         S2    = CClose - ( CHigh - CLow ) * 1.1 / 6;
         S3    = CClose - ( CHigh - CLow ) * 1.1 / 4;
         S4    = CClose - ( CHigh - CLow ) * 1.1 / 2;

         ObjectCreate ( "Label", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label", "Camarilla pivot points:", 8, "Courier New", White );

         YY += dYY;
         ObjectCreate ( "R4", OBJ_TREND, 0, Time [CTime], R4, Time[0]+10, R4 );
         ObjectSet ( "R4", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R4 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R4=", R4, "    dR4=", iLabel );
         ObjectCreate ( "Label_R4", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R4", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R4", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R4", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R4", sLabel, 8, "Courier New", R_Color );

         YY += dYY;
         ObjectCreate ( "R3", OBJ_TREND, 0, Time [CTime], R3, Time[0]+10, R3 );
         ObjectSet ( "R3", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R3 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R3=", R3, "    dR3=", iLabel );
         ObjectCreate ( "Label_R3", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R3", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R3", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R3", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R3", sLabel, 8, "Courier New", R_Color );
         
         YY += dYY;
         ObjectCreate ( "R2", OBJ_TREND, 0, Time [CTime], R2, Time[0]+10, R2 );
         ObjectSet ( "R2", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R2 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R2=", R2, "    dR2=", iLabel );
         ObjectCreate ( "Label_R2", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R2", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R2", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R2", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R2", sLabel, 8, "Courier New", R_Color );

         YY += dYY;
         ObjectCreate ( "R1", OBJ_TREND, 0, Time [CTime], R1, Time[0]+10, R1 );
         ObjectSet ( "R1", OBJPROP_COLOR, R_Color );
         iLabel = MathFloor ( ( R1 - Price ) * 10000 ); 
         sLabel = StringConcatenate ( "R1=", R1, "    dR1=", iLabel );
         ObjectCreate ( "Label_R1", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_R1", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_R1", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_R1", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_R1", sLabel, 8, "Courier New", R_Color );

         YY += dYY;
         ObjectCreate ( "S1", OBJ_TREND, 0, Time [CTime], S1, Time[0]+10, S1 );
         ObjectSet ( "S1", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S1 ) * 10000 ); 
         sLabel = StringConcatenate ( "S1=", S1, "    dS1=", iLabel );
         ObjectCreate ( "Label_S1", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S1", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S1", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S1", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S1", sLabel, 8, "Courier New", S_Color );

         YY += dYY;
         ObjectCreate ( "S2", OBJ_TREND, 0, Time [CTime], S2, Time[0]+10, S2 );
         ObjectSet ( "S2", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S2 ) * 10000 ); 
         sLabel = StringConcatenate ( "S2=", S2, "    dS2=", iLabel );
         ObjectCreate ( "Label_S2", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S2", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S2", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S2", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S2", sLabel, 8, "Courier New", S_Color );

         YY += dYY;
         ObjectCreate ( "S3", OBJ_TREND, 0, Time [CTime], S3, Time[0]+10, S3 );
         ObjectSet ( "S3", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S3 ) * 10000 ); 
         sLabel = StringConcatenate ( "S3=", S3, "    dS3=", iLabel );
         ObjectCreate ( "Label_S3", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S3", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S3", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S3", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S3", sLabel, 8, "Courier New", S_Color );

         YY += dYY;
         ObjectCreate ( "S4", OBJ_TREND, 0, Time [CTime], S4, Time[0]+10, S4 );
         ObjectSet ( "S4", OBJPROP_COLOR, S_Color );
         iLabel = MathFloor ( ( Price - S4 ) * 10000 ); 
         sLabel = StringConcatenate ( "S4=", S4, "    dS4=", iLabel );
         ObjectCreate ( "Label_S4", OBJ_LABEL, 0, 0, 0 );
         ObjectSet    ( "Label_S4", OBJPROP_CORNER, 1 );
         ObjectSet    ( "Label_S4", OBJPROP_XDISTANCE, XX );
         ObjectSet    ( "Label_S4", OBJPROP_YDISTANCE, YY );
         ObjectSetText( "Label_S4", sLabel, 8, "Courier New", S_Color );
      }   

//      double val1=ObjectGetValueByShift("R1", 0);
//      if (Bid-Alert_Red*Point <= val1 && Bid+Alert_Red*Point >= val1)
//     {   if (Sound_Alert_Red) PlaySound (AlertSound);
//         if (PopupON) Alert (Symbol()," price within ",Alert_Red," pips of ","R1");
//         if (EmailON) SendMail(Symbol()+" ",Alert_Red+" pips from "+"R1");  
//     }   
   return(0);
  }
//+-------------------------------------------------------------------------------------------------+