Pivot-Calculator

Download script
Author:
Pivot-Calculator

This script functions as an automated technical analysis tool for MetaTrader, designed to project key Support and Resistance levels on your trading chart based on historical price action. By identifying these "Pivot Points," the tool helps traders visualize potential areas where the market might encounter significant buying or selling pressure.

Core Functionality

1. Historical Data Analysis The logic begins by scanning previous trading sessions to identify critical price benchmarks. It specifically looks for the highest price reached (High), the lowest price reached (Low), and the closing price of the preceding day. It is programmed to be intelligent regarding weekends; if it detects a Monday, it will automatically look back to the previous Friday to ensure the data remains relevant.

2. Pivot Point Calculations Using the high, low, and close prices from the previous session, the script performs a series of mathematical calculations to generate several layers of price levels:

  • Standard Pivot: The central equilibrium point for the current trading day.
  • Support & Resistance (S1–S3, R1–R3): These represent the primary boundaries. "Resistance" levels are price ceilings where selling pressure may increase, while "Support" levels are floors where buying interest may emerge.
  • Mid-Levels (MR1–MR3, MS1–MS3): These provide more granular data by calculating the halfway points between the main pivots and the primary support/resistance zones.
  • Mid-Mid Levels (MMR1–MMR6, MMS1–MMS6): This is a high-detail layer that breaks down the zones even further, providing very specific price targets for scalping or precise entries.

3. Visual Representation Instead of just calculating numbers in the background, the script dynamically draws these levels directly onto your chart as horizontal lines.

  • Customization: Users can personalize the visual experience by changing colors (e.g., White for Pivots, Aqua for Support/Resistance, LimeGreen for Mid-levels) and adjusting line thickness or styles (solid, dashed, etc.).
  • Automatic Labeling: To ensure clarity, the script automatically places text labels next to each line (e.g., "R1", "S2", "MMR3"). These labels are programmed to stay pinned to the correct price level as the chart updates.
  • Dynamic Cleanup: The script is designed to be efficient; it clears old objects and redraws them as necessary, ensuring that your chart remains clean and reflects only the most current data available for the current session.

How to Use This Logic

A trader uses this tool to anticipate where price might stall or reverse. When the price approaches a Resistance (R) line, a trader might look for selling opportunities, whereas an approach toward a Support (S) line might signal a potential buying opportunity. The additional "Mid" and "Mid-Mid" levels allow for even finer navigation of these zones, helping to identify smaller fluctuations within larger trends.

Price Data Components
Series array that contains open time of each bar
13 Views
0 Downloads
0 Favorites
Pivot-Calculator
//+------------------------------------------------------------------+
//|           Included is the PRICE based Pivot calculator           |
//|                (Daily Pivot,R1,R2,R3 & S1,S2,S3)                 |
//|                                                                  |
//|                                 Email: Xard777@connectfree.co.uk |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property indicator_chart_window


extern int P = 5; //How many days back /0 = curr day/ 1 = yesterday/ 2= 2days ago
extern color PivotColor = White; // Color of both the label and level of pivot
extern color SandRColor = Aqua; // Color of both the label and level of S&R
extern color MidColor = LimeGreen; // Color of both the label and level mids
extern color MMidColor = Violet; // Color of both the label and level midmids

// Style definition are in the range [0,4]
// STYLE_SOLID, STYLE_DASH, STYLE_DOT, STYLE_DASHDOT, STYLE_DASHDOTDOT
extern int PsrStyle = STYLE_SOLID; // Solid level for pivot and S & Rs
extern int MidStyle = STYLE_SOLID; // Solid level for mids
extern int MMidStyle = STYLE_SOLID; // Solid level for midmids

// Line thickness are in the range [1,5]:
extern int PsrWidth = 3; // Thickness for pivot and S & Rs
extern int MidWidth = 2; // Thickness for mids
extern int MMidWidth = 1; // Thickness for midmids

//---- input parameters ----
int fontsize = 10;
double LastHigh, LastLow, x;

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{

  ObjectsDeleteAll();   
  return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- Name for DataWindow and indicator subwindow label
   IndicatorShortName("XA"); 
   SetIndexDrawBegin(0,1);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));

   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{

   int counted_bars = IndicatorCounted();
   int limit, i;
   
   //---- Indicator Calculation ----
   if(counted_bars == 0)
   {
       x = Period();
       if(x > 240) 
           return(-1);       
   }
   if(counted_bars < 0) 
       return(-1);
   
   //---- last counted bar will be recounted
   limit = (Bars - counted_bars) - 1;
   for(i = limit; i >= 0; i--)
   { 
       if(High[i+1] > LastHigh) 
           LastHigh = High[i+1];
       //----
       if(Low[i+1] < LastLow) 
           LastLow=Low[i+1];
       if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
       { 
           LastLow = Open[i]; 
           LastHigh = Open[i];
       }
      
   //---- Pivot Setup ----
   double rates[1][6],yesterday_volume,yesterday_close,yesterday_high,yesterday_low,yesterday_open;
   ArrayCopyRates(rates, Symbol(), PERIOD_D1);

   if(DayOfWeek() == 1)
   {
      if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,1)) == 5)
      {
          yesterday_volume = rates[1][5];
          yesterday_close = rates[1][4];
          yesterday_high = rates[1][3];
          yesterday_low = rates[1][2];
          yesterday_open = rates[1][1];
      }
      else
      {
         for(int d = 5;d>=0;d--)
         {
            if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,d)) == 5)
            {
                yesterday_volume = rates[d][5];
                yesterday_close = rates[d][4];
                yesterday_high = rates[d][3];
                yesterday_low = rates[d][2];
                yesterday_open = rates[d][1];
            }
         }  
      }
   }
   else
   {
       yesterday_close = rates[1][4];
       yesterday_high = rates[1][3];
       yesterday_low = rates[1][2];
       yesterday_open = rates[1][1];
   }

   //---- Calculate Pivots ----
   double R = yesterday_high - yesterday_low;//range
   double p = (yesterday_high + yesterday_low + yesterday_close)/3;// Standard Pivot
   double r3 = (2*p)+(yesterday_high-(2*yesterday_low));// Resistance 3
   double r2 = p+(yesterday_high - yesterday_low);// Resistance point 2
   double r1 = (2*p)-yesterday_low;// Resistance point 1
   double s1 = (2*p)-yesterday_high;// Support point 1
   double s2 = p-(yesterday_high - yesterday_low);// Support point 2
   double s3 = (2*p)-((2* yesterday_high)-yesterday_low);// Support point 3

   double mr1 = 0.5*(p+r1);
   double mr2 = 0.5*(r1+r2);
   double mr3 = 0.5*(r2+r3);
   double ms1 = 0.5*(p+s1);
   double ms2 = 0.5*(s1+s2);
   double ms3 = 0.5*(s2+s3);
   
   double mmr1 = 0.5*(p+mr1);
   double mmr2 = 0.5*(mr1+r1);
   double mmr3 = 0.5*(r1+mr2);
   double mmr4 = 0.5*(mr2+r2);
   double mmr5 = 0.5*(r2+mr3);
   double mmr6 = 0.5*(mr3+r3);
   
   double mms1 = 0.5*(p+ms1);
   double mms2 = 0.5*(ms1+s1);
   double mms3 = 0.5*(s1+ms2);
   double mms4 = 0.5*(ms2+s2);
   double mms5 = 0.5*(s2+ms3);
   double mms6 = 0.5*(ms3+s3);
   
   //Pivot, Support & Resistance Lines
   ObjectDelete("p_Line");
   ObjectCreate("p_Line", OBJ_HLINE,0, CurTime(),p);
   ObjectSet("p_Line",OBJPROP_COLOR,PivotColor);
   ObjectSet("p_Line",OBJPROP_STYLE,PsrStyle);
   ObjectSet("p_Line",OBJPROP_WIDTH,PsrWidth);

   ObjectDelete("r1_Line");
   ObjectCreate("r1_Line", OBJ_HLINE,0, CurTime(),r1);
   ObjectSet("r1_Line",OBJPROP_COLOR,SandRColor);
   ObjectSet("r1_Line",OBJPROP_STYLE,PsrStyle);
   ObjectSet("r1_Line",OBJPROP_WIDTH,PsrWidth);

   ObjectDelete("r2_Line");
   ObjectCreate("r2_Line", OBJ_HLINE,0, CurTime(),r2);
   ObjectSet("r2_Line",OBJPROP_COLOR,SandRColor);
   ObjectSet("r2_Line",OBJPROP_STYLE,PsrStyle);
   ObjectSet("r2_Line",OBJPROP_WIDTH,PsrWidth);

   ObjectDelete("r3_Line");
   ObjectCreate("r3_Line", OBJ_HLINE,0, CurTime(),r3);
   ObjectSet("r3_Line",OBJPROP_COLOR,SandRColor);
   ObjectSet("r3_Line",OBJPROP_STYLE,PsrStyle);
   ObjectSet("r3_Line",OBJPROP_WIDTH,PsrWidth);

   ObjectDelete("s1_Line");
   ObjectCreate("s1_Line", OBJ_HLINE,0, CurTime(),s1);
   ObjectSet("s1_Line",OBJPROP_COLOR,SandRColor);
   ObjectSet("s1_Line",OBJPROP_STYLE,PsrStyle);
   ObjectSet("s1_Line",OBJPROP_WIDTH,PsrWidth);

   ObjectDelete("s2_Line");
   ObjectCreate("s2_Line", OBJ_HLINE,0, CurTime(),s2);
   ObjectSet("s2_Line",OBJPROP_COLOR,SandRColor);
   ObjectSet("s2_Line",OBJPROP_STYLE,PsrStyle);
   ObjectSet("s2_Line",OBJPROP_WIDTH,PsrWidth);

   ObjectDelete("s3_Line");
   ObjectCreate("s3_Line", OBJ_HLINE,0, CurTime(),s3);
   ObjectSet("s3_Line",OBJPROP_COLOR,SandRColor);
   ObjectSet("s3_Line",OBJPROP_STYLE,PsrStyle);
   ObjectSet("s3_Line",OBJPROP_WIDTH,PsrWidth);

   ObjectDelete("mr1_Line");
   ObjectCreate("mr1_Line", OBJ_HLINE,0, CurTime(),mr1);
   ObjectSet("mr1_Line",OBJPROP_COLOR,MidColor);
   ObjectSet("mr1_Line",OBJPROP_STYLE,MidStyle);
   ObjectSet("mr1_Line",OBJPROP_WIDTH,MidWidth);

   ObjectDelete("mr2_Line");
   ObjectCreate("mr2_Line", OBJ_HLINE,0, CurTime(),mr2);
   ObjectSet("mr2_Line",OBJPROP_COLOR,MidColor);
   ObjectSet("mr2_Line",OBJPROP_STYLE,MidStyle);
   ObjectSet("mr2_Line",OBJPROP_WIDTH,MidWidth);

   ObjectDelete("mr3_Line");
   ObjectCreate("mr3_Line", OBJ_HLINE,0, CurTime(),mr3);
   ObjectSet("mr3_Line",OBJPROP_COLOR,MidColor);
   ObjectSet("mr3_Line",OBJPROP_STYLE,MidStyle);
   ObjectSet("mr3_Line",OBJPROP_WIDTH,MidWidth);

   ObjectDelete("ms1_Line");
   ObjectCreate("ms1_Line", OBJ_HLINE,0, CurTime(),ms1);
   ObjectSet("ms1_Line",OBJPROP_COLOR,MidColor);
   ObjectSet("ms1_Line",OBJPROP_STYLE,MidStyle);
   ObjectSet("ms1_Line",OBJPROP_WIDTH,MidWidth);

   ObjectDelete("ms2_Line");
   ObjectCreate("ms2_Line", OBJ_HLINE,0, CurTime(),ms2);
   ObjectSet("ms2_Line",OBJPROP_COLOR,MidColor);
   ObjectSet("ms2_Line",OBJPROP_STYLE,MidStyle);
   ObjectSet("ms2_Line",OBJPROP_WIDTH,MidWidth);

   ObjectDelete("ms3_Line");
   ObjectCreate("ms3_Line", OBJ_HLINE,0, CurTime(),ms3);
   ObjectSet("ms3_Line",OBJPROP_COLOR,MidColor);
   ObjectSet("ms3_Line",OBJPROP_STYLE,MidStyle);
   ObjectSet("ms3_Line",OBJPROP_WIDTH,MidWidth);

   ObjectDelete("mmr1_Line");
   ObjectCreate("mmr1_Line", OBJ_HLINE,0, CurTime(),mmr1);
   ObjectSet("mmr1_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mmr1_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mmr1_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mmr2_Line");
   ObjectCreate("mmr2_Line", OBJ_HLINE,0, CurTime(),mmr2);
   ObjectSet("mmr2_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mmr2_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mmr2_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mmr3_Line");
   ObjectCreate("mmr3_Line", OBJ_HLINE,0, CurTime(),mmr3);
   ObjectSet("mmr3_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mmr3_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mmr3_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mmr4_Line");
   ObjectCreate("mmr4_Line", OBJ_HLINE,0, CurTime(),mmr4);
   ObjectSet("mmr4_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mmr4_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mmr4_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mmr5_Line");
   ObjectCreate("mmr5_Line", OBJ_HLINE,0, CurTime(),mmr5);
   ObjectSet("mmr5_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mmr5_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mmr5_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mmr6_Line");
   ObjectCreate("mmr6_Line", OBJ_HLINE,0, CurTime(),mmr6);
   ObjectSet("mmr6_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mmr6_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mmr6_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mms1_Line");
   ObjectCreate("mms1_Line", OBJ_HLINE,0, CurTime(),mms1);
   ObjectSet("mms1_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mms1_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mms1_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mms2_Line");
   ObjectCreate("mms2_Line", OBJ_HLINE,0, CurTime(),mms2);
   ObjectSet("mms2_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mms2_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mms2_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mms3_Line");
   ObjectCreate("mms3_Line", OBJ_HLINE,0, CurTime(),mms3);
   ObjectSet("mms3_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mms3_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mms3_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mms4_Line");
   ObjectCreate("mms4_Line", OBJ_HLINE,0, CurTime(),mms4);
   ObjectSet("mms4_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mms4_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mms4_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mms5_Line");
   ObjectCreate("mms5_Line", OBJ_HLINE,0, CurTime(),mms5);
   ObjectSet("mms5_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mms5_Line",OBJPROP_STYLE,MMidStyle);
   ObjectSet("mms5_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectDelete("mms6_Line");
   ObjectCreate("mms6_Line", OBJ_HLINE,0, CurTime(),mms6);
   ObjectSet("mms6_Line",OBJPROP_COLOR,MMidColor);
   ObjectSet("mms6_Line",OBJPROP_STYLE,PsrStyle);
   ObjectSet("mms6_Line",OBJPROP_WIDTH,MMidWidth);

   ObjectsRedraw();

   // ---- Typing Labels ----

   //MMR6 Label
   if(ObjectFind("MMR6 label") != 0)
   {
      ObjectCreate("MMR6 label", OBJ_TEXT, 0, Time[3], mmr6);
      ObjectSetText("MMR6 label", " MMR6 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMR6 label", 0, Time[3], mmr6);
   }

   //MMR5 Label
   if(ObjectFind("MMR5 label") != 0)
   {
      ObjectCreate("MMR5 label", OBJ_TEXT, 0, Time[3], mmr5);
      ObjectSetText("MMR5 label", " MMR5 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMR5 label", 0, Time[3], mmr5);
   }

   //MMR4 Label
   if(ObjectFind("MMR4 label") != 0)
   {
      ObjectCreate("MMR4 label", OBJ_TEXT, 0, Time[3], mmr4);
      ObjectSetText("MMR4 label", " MMR4 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMR4 label", 0, Time[3], mmr4);
   }

   //MMR3 Label
   if(ObjectFind("MMR3 label") != 0)
   {
      ObjectCreate("MMR3 label", OBJ_TEXT, 0, Time[3], mmr3);
      ObjectSetText("MMR3 label", " MMR3 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMR3 label", 0, Time[3], mmr3);
   }

   //MMR2 Label
   if(ObjectFind("MMR2 label") != 0)
   {
      ObjectCreate("MMR2 label", OBJ_TEXT, 0, Time[3], mmr2);
      ObjectSetText("MMR2 label", " MMR2 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMR2 label", 0, Time[3], mmr2);
   }

   //MMR1 Label
   if(ObjectFind("MMR1 label") != 0)
   {
      ObjectCreate("MMR1 label", OBJ_TEXT, 0, Time[3], mmr1);
      ObjectSetText("MMR1 label", " MMR1 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMR1 label", 0, Time[3], mmr1);
   }
   
   //MMS6 Label
   if(ObjectFind("MMS6 label") != 0)
   {
      ObjectCreate("MMS6 label", OBJ_TEXT, 0, Time[3], mms6);
      ObjectSetText("MMS6 label", " MMS6 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMS6 label", 0, Time[3], mms6);
   }

   //MMS5 Label
   if(ObjectFind("MMS5 label") != 0)
   {
      ObjectCreate("MMS5 label", OBJ_TEXT, 0, Time[3], mms5);
      ObjectSetText("MMS5 label", " MMS5 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMS5 label", 0, Time[3], mms5);
   }

   //MMS4 Label
   if(ObjectFind("MMS4 label") != 0)
   {
      ObjectCreate("MMS4 label", OBJ_TEXT, 0, Time[3], mms4);
      ObjectSetText("MMS4 label", " MMS4 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMS4 label", 0, Time[3], mms4);
   }

   //MMS3 Label
   if(ObjectFind("MMS3 label") != 0)
   {
      ObjectCreate("MMS3 label", OBJ_TEXT, 0, Time[3], mms3);
      ObjectSetText("MMS3 label", " MMS3 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMS3 label", 0, Time[3], mms3);
   }

   //MMS2 Label
   if(ObjectFind("MMS2 label") != 0)
   {
      ObjectCreate("MMS2 label", OBJ_TEXT, 0, Time[3], mms2);
      ObjectSetText("MMS2 label", " MMS2 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMS2 label", 0, Time[3], mms2);
   }

   //MMS1 Label
   if(ObjectFind("MMS1 label") != 0)
   {
      ObjectCreate("MMS1 label", OBJ_TEXT, 0, Time[3], mms1);
      ObjectSetText("MMS1 label", " MMS1 ", 9, "Verdana", MMidColor);
   }
   else
   {
      ObjectMove("MMS1 label", 0, Time[3], mms1);
   }

   //MR3 Label
   if(ObjectFind("MR3 label") != 0)
   {
      ObjectCreate("MR3 label", OBJ_TEXT, 0, Time[3], mr3);
      ObjectSetText("MR3 label", " MR3 ", 9, "Verdana", MidColor);
   }
   else
   {
      ObjectMove("MR3 label", 0, Time[3], mr3);
   }

   //MR2 Label
   if(ObjectFind("MR2 label") != 0)
   {
      ObjectCreate("MR2 label", OBJ_TEXT, 0, Time[3], mr2);
      ObjectSetText("MR2 label", " MR2 ", 9, "Verdana", MidColor);
   }
   else
   {
      ObjectMove("MR2 label", 0, Time[3], mr2);
   }

   //MR1 Label
   if(ObjectFind("MR1 label") != 0)
   {
      ObjectCreate("MR1 label", OBJ_TEXT, 0, Time[3], mr1);
      ObjectSetText("MR1 label", " MR1 ", 9, "Verdana", MidColor);
   }
   else
   {
      ObjectMove("MR1 label", 0, Time[3], mr1);
   }

   //MS3 Label
   if(ObjectFind("MS3 label") != 0)
   {
      ObjectCreate("MS3 label", OBJ_TEXT, 0, Time[3], ms3);
      ObjectSetText("MS3 label", " MS3 ", 9, "Verdana", MidColor);
   }
   else
   {
      ObjectMove("MS3 label", 0, Time[3], ms3);
   }

   //MS2 Label
   if(ObjectFind("MS2 label") != 0)
   {
      ObjectCreate("MS2 label", OBJ_TEXT, 0, Time[3], ms2);
      ObjectSetText("MS2 label", " MS2 ", 9, "Verdana", MidColor);
   }
   else
   {
      ObjectMove("MS2 label", 0, Time[3], ms2);
   }

   //MS1 Label
   if(ObjectFind("MS1 label") != 0)
   {
      ObjectCreate("MS1 label", OBJ_TEXT, 0, Time[3], ms1);
      ObjectSetText("MS1 label", " MS1 ", 9, "Verdana", MidColor);
   }
   else
   {
      ObjectMove("MS1 label", 0, Time[3], ms1);
   }

   //R3 Label
   if(ObjectFind("R3 label") != 0)
   {
      ObjectCreate("R3 label", OBJ_TEXT, 0, Time[3], r3);
      ObjectSetText("R3 label", " R3 ", 9, "Verdana", SandRColor);
   }
   else
   {
      ObjectMove("R3 label", 0, Time[3], r3);
   }

   //S3 Label   
   if(ObjectFind("S3 label") != 0)
   {
      ObjectCreate("S3 label", OBJ_TEXT, 0, Time[3], s3);
      ObjectSetText("S3 label", " S3 ", 9, "Verdana", SandRColor);
   }
   else
   {
      ObjectMove("S3 label", 0, Time[3], s3);
   }

   //R2 Label 
   if(ObjectFind("R2 label") != 0)
   {
      ObjectCreate("R2 label", OBJ_TEXT, 0, Time[3], r2);
      ObjectSetText("R2 label", " R2 ", 9, "Verdana", SandRColor);
   }
   else
   {
      ObjectMove("R2 label", 0, Time[3], r2);
   }

   //S2 Label 
   if(ObjectFind("S2 label") != 0)
   {
      ObjectCreate("S2 label", OBJ_TEXT, 0, Time[3], s2);
      ObjectSetText("S2 label", " S2 ", 9, "Verdana", SandRColor);
   }
   else
   {
      ObjectMove("S2 label", 0, Time[3], s2);
   }

   //R1 Label
   if(ObjectFind("R1 label") != 0)
   {
      ObjectCreate("R1 label", OBJ_TEXT, 0, Time[3], r1);
      ObjectSetText("R1 label", " R1 ", 9, "Verdana", SandRColor);
   }
   else
   {
      ObjectMove("R1 label", 0, Time[3], r1);
   }

   //S1 Label
   if(ObjectFind("S1 label") != 0)
   {
      ObjectCreate("S1 label", OBJ_TEXT, 0, Time[3], s1);
      ObjectSetText("S1 label", " S1 ", 9, "Verdana", SandRColor);
   }
   else
   {
      ObjectMove("S1 label", 0, Time[3], s1);
   }

   //Pivot Label
   if(ObjectFind("P label") != 0)
   {
      ObjectCreate("P label", OBJ_TEXT, 0, Time[3], p);
      ObjectSetText("P label", " Pivot ", 9, "Verdana", PivotColor);
   }
   else
   {
      ObjectMove("P label", 0, Time[3], p);
   }  
 
   Comment("Pivot Calculator ");

   }

   return(0);
   
}
//Job Done
//+------------------------------------------------------------------+

Comments