Pivot Manual

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
Pivot Manual

This script is designed to automatically calculate and draw various technical analysis levels on a trading chart based on the previous day's market activity. Instead of requiring you to manually calculate these figures, the tool takes three specific data points from yesterday—the High price, the Low price, and the Closing price—and uses them to project several different types of support and resistance zones.

Core Logic and Visual Layout

The script organizes the chart by creating a series of horizontal lines and text labels. Each set of lines represents a different mathematical model used by traders to identify potential turning points in price action:

1. Classic Pivot Points The primary "Pivot" is the central balance point calculated from yesterday's high, low, and close. From this center, the script generates:

  • Resistance Levels (R1, R2, R3): These indicate potential ceilings where price might face selling pressure.
  • Support Levels (S1, S2, S3): These indicate potential floors where price might find buying interest.

2. Fibonacci-Based Levels The script incorporates "Fib" levels (Fr1, Fr2, Fr3 and Fs1, Fs2, Fs3). These are derived using specific ratios applied to the range between yesterday’s high and low. These levels are often used to identify deeper retracement points or extended price targets.

3. Mid-Point Transitions A series of "M" levels (M0 through M5) are plotted. These represent the halfway marks between various major support and resistance points. They act as "sub-zones," helping traders see the transition areas between major price moves.

4. Custom High/Low Projections The script also calculates a unique set of high (H3–H5) and low (L3–L5) projections. These are weighted calculations based on the relationship between yesterday's close and its total range, providing additional layers of potential price boundaries.

Visual Organization

To make the chart easy to read, the script assigns distinct styles to these different categories:

  • Pivot Lines: Displayed as dashed lines in Magenta.
  • Support/Resistance: Use Aqua (Support) and Red (Resistance) colors with dash-dot patterns.
  • Fibonacci Levels: Marked with Brown lines.
  • High/Low Projections: Solid lines in SpringGreen (for highs) and Red (for lows).

Summary for the User

When you run this script, it takes the "memory" of yesterday's price movement and maps out a roadmap for today. By looking at where these lines appear, you can see where historical math suggests the price might stall, reverse, or find balance, allowing for a more organized view of potential trading opportunities.

10 Views
0 Downloads
0 Favorites
Pivot Manual
//+------------------------------------------------------------------+
//|                                                  Pivot Manual.mq4|
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_chart_window

extern double Yesterdays_High = 1.9839;
extern double Yesterdays_Low = 1.9725;
extern double Yesterdays_Close = 1.9811;
int LabelShift = 20;
int LineShift = 40;
datetime LabelShiftTime, LineShiftTime;
datetime LabelShiftTimeC, LabelShiftTimeF, LabelShiftTimeM;

//---- input parameters

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init(){

   
   //----
   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit(){
ObjectsDeleteAll(); 
   
   //----
   return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start(){
  
 double YH = Yesterdays_High ;
 double YL = Yesterdays_Low ;
 double YC = Yesterdays_Close ; 
 double R = YH - YL ; 
 
 double Pivot = (YH + YC + YL)/3;
 
 double R1 = (Pivot * 2)- YL;
 double R2 = Pivot + (YH - YL);
 double R3 = YH + (2 *(Pivot - YL));
 double S1 = (Pivot * 2)- YH;
 double S2 = Pivot - (YH - YL);
 double S3 = YL - (2 *(YH - Pivot));
 
 double H5 = (YH/YL)*YC;
 double H4 = ((YH - YL)* 0.55) + YC;
 double H3 = ((YH - YL)* 0.275) + YC;
 double L3 = YC - ((YH - YL)*(0.275));
 double L4 = YC - ((YH - YL)*(0.55));
 double L5 = YC - (H5 - YC);
 
 double Fr1 = Pivot + (R * 0.382);
 double Fr2 = Pivot + (R * 0.618);
 double Fr3 = Pivot + (R * 1);
 double Fs1 = Pivot - (R * 0.382);
 double Fs2 = Pivot - (R * 0.618);
 double Fs3 = Pivot - (R * 1);
 
 double M0 = (S2+S3)/2;
 double M1 = (S1+S2)/2;
 double M2 = (Pivot+S1)/2;
 double M3 = (Pivot+R1)/2;
 double M4 = (R1+R2)/2;
 double M5 = (R2+R3)/2;
 
 
LabelShiftTime = Time[LabelShift];
LineShiftTime = Time[LineShift];
LabelShiftTimeC = Time[LabelShift - 3];
LabelShiftTimeF = Time[LabelShift + 3];
LabelShiftTimeM = Time[LabelShift];

      ObjectCreate("P label", OBJ_TEXT, 0, LabelShiftTime, Pivot);
      ObjectSetText("P label", "Pivot", 8, "Arial", White);
      
      ObjectCreate("P line", OBJ_HLINE, 0, LineShiftTime, Pivot);
      ObjectSet("P line", OBJPROP_STYLE, STYLE_DASH);
      ObjectSet("P line", OBJPROP_COLOR, Magenta);
      
      ObjectCreate("R1 label", OBJ_TEXT, 0, LabelShiftTime, R1);
      ObjectSetText("R1 label", " R1", 8, "Arial", White);
      
      ObjectCreate("R2 label", OBJ_TEXT, 0, LabelShiftTime, R2);
      ObjectSetText("R2 label", " R2", 8, "Arial", White);

      ObjectCreate("R3 label", OBJ_TEXT, 0, LabelShiftTime, R3);
      ObjectSetText("R3 label", " R3", 8, "Arial", White);

      ObjectCreate("S1 label", OBJ_TEXT, 0, LabelShiftTime, S1);
      ObjectSetText("S1 label", "S1", 8, "Arial", White);

      ObjectCreate("S2 label", OBJ_TEXT, 0, LabelShiftTime, S2);
      ObjectSetText("S2 label", "S2", 8, "Arial", White);

      ObjectCreate("S3 label", OBJ_TEXT, 0, LabelShiftTime, S3);
      ObjectSetText("S3 label", "S3", 8, "Arial", White);


      ObjectCreate("S1 line", OBJ_HLINE, 0, LineShiftTime, S1);
      ObjectSet("S1 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("S1 line", OBJPROP_COLOR, Aqua);

      ObjectCreate("S2 line", OBJ_HLINE, 0, LineShiftTime, S2);
      ObjectSet("S2 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("S2 line", OBJPROP_COLOR, Aqua);

      ObjectCreate("S3 line", OBJ_HLINE, 0, LineShiftTime, S3);
      ObjectSet("S3 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("S3 line", OBJPROP_COLOR, Aqua);

      ObjectCreate("R1 line", OBJ_HLINE, 0, LineShiftTime, R1);
      ObjectSet("R1 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("R1 line", OBJPROP_COLOR, Red);

      ObjectCreate("R2 line", OBJ_HLINE, 0, LineShiftTime, R2);
      ObjectSet("R2 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("R2 line", OBJPROP_COLOR, Red);
  
      ObjectCreate("R3 line", OBJ_HLINE, 0, LineShiftTime, R3);
      ObjectSet("R3 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("R3 line", OBJPROP_COLOR, Red);


      ObjectCreate("M5 label", OBJ_TEXT, 0, LabelShiftTimeM, M5);
      ObjectSetText("M5 label", " M5", 8, "Arial", Silver);

      ObjectCreate("M4 label", OBJ_TEXT, 0, LabelShiftTimeM, M4);
      ObjectSetText("M4 label", " M4", 8, "Arial", Silver);
 
      ObjectCreate("M3 label", OBJ_TEXT, 0, LabelShiftTimeM, M3);
      ObjectSetText("M3 label", " M3", 8, "Arial", Silver);

      ObjectCreate("M2 label", OBJ_TEXT, 0, LabelShiftTimeM, M2);
      ObjectSetText("M2 label", " M2", 8, "Arial", Silver);

      ObjectCreate("M1 label", OBJ_TEXT, 0, LabelShiftTimeM, M1);
      ObjectSetText("M1 label", " M1", 8, "Arial", Silver);

      ObjectCreate("M0 label", OBJ_TEXT, 0, LabelShiftTimeM, M0);
      ObjectSetText("M0 label", " M0", 8, "Arial", Silver);

      ObjectCreate("M5 line", OBJ_HLINE, 0, LineShiftTime, M5);
      ObjectSet("M5 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("M5 line", OBJPROP_COLOR, Silver);

      ObjectCreate("M4 line", OBJ_HLINE, 0, LineShiftTime, M4);
      ObjectSet("M4 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("M4 line", OBJPROP_COLOR, Silver);

      ObjectCreate("M3 line", OBJ_HLINE, 0, LineShiftTime, M3);
      ObjectSet("M3 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("M3 line", OBJPROP_COLOR, Silver);

      ObjectCreate("M2 line", OBJ_HLINE, 0, LineShiftTime, M2);
      ObjectSet("M2 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("M2 line", OBJPROP_COLOR, Silver);

      ObjectCreate("M1 line", OBJ_HLINE, 0, LineShiftTime, M1);
      ObjectSet("M1 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("M1 line", OBJPROP_COLOR, Silver);
  
      ObjectCreate("M0 line", OBJ_HLINE, 0, LineShiftTime, M0);
      ObjectSet("M0 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet("M0 line", OBJPROP_COLOR, Silver);
  
     
        ObjectCreate("FibR1 label", OBJ_TEXT, 0, LabelShiftTimeF, Fr1);
        ObjectSetText("FibR1 label", "Fib R1", 8, "Arial", White);

        ObjectCreate("FibR2 label", OBJ_TEXT, 0, LabelShiftTimeF, Fr2);
        ObjectSetText("FibR2 label", "Fib R2", 8, "Arial", White);

        ObjectCreate("FibR3 label", OBJ_TEXT, 0, LabelShiftTimeF, Fr3);
        ObjectSetText("FibR3 label", "Fib R3", 8, "Arial", White);

        ObjectCreate("FibS1 label", OBJ_TEXT, 0, LabelShiftTimeF, Fs1);
        ObjectSetText("FibS1 label", "Fib S1", 8, "Arial", White);

        ObjectCreate("FibS2 label", OBJ_TEXT, 0, LabelShiftTimeF, Fs2);
        ObjectSetText("FibS2 label", "Fib S2", 8, "Arial", White);
 
        ObjectCreate("FibS3 label", OBJ_TEXT, 0, LabelShiftTimeF, Fs3);
        ObjectSetText("FibS3 label", "Fib S3", 8, "Arial", White);

        ObjectCreate("FibS1 line", OBJ_HLINE, 0, LineShiftTime, Fs1);
        ObjectSet("FibS1 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
        ObjectSet("FibS1 line", OBJPROP_COLOR, Brown);

        ObjectCreate("FibS2 line", OBJ_HLINE, 0, LineShiftTime, Fs2);
        ObjectSet("FibS2 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
        ObjectSet("FibS2 line", OBJPROP_COLOR, Brown);

        ObjectCreate("FibS3 line", OBJ_HLINE, 0, LineShiftTime, Fs3);
        ObjectSet("FibS3 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
        ObjectSet("FibS3 line", OBJPROP_COLOR, Brown);

        ObjectCreate("FibR1 line", OBJ_HLINE, 0, LineShiftTime, Fr1);
        ObjectSet("FibR1 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
        ObjectSet("FibR1 line", OBJPROP_COLOR, Brown);

        ObjectCreate("FibR2 line", OBJ_HLINE, 0, LineShiftTime, Fr2);
        ObjectSet("FibR2 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
        ObjectSet("FibR2 line", OBJPROP_COLOR, Brown);

        ObjectCreate("FibR3 line", OBJ_HLINE, 0, LineShiftTime, Fr3);
        ObjectSet("FibR3 line", OBJPROP_STYLE, STYLE_DASHDOTDOT);
        ObjectSet("FibR3 line", OBJPROP_COLOR, Brown);
 
   

      ObjectCreate("H5 label", OBJ_TEXT, 0, LabelShiftTimeC, H5);
      ObjectSetText("H5 label", " H5 ", 8, "Arial", White);
  
      ObjectCreate("H4 label", OBJ_TEXT, 0, LabelShiftTimeC, H4);
      ObjectSetText("H4 label", " H4 ", 8, "Arial", White);
 
      ObjectCreate("H3 label", OBJ_TEXT, 0, LabelShiftTimeC, H3);
      ObjectSetText("H3 label", " H3 ", 8, "Arial", White);

      ObjectCreate("L3 label", OBJ_TEXT, 0, LabelShiftTimeC, L3);
      ObjectSetText("L3 label", " L3 ", 8, "Arial", White);
 
      ObjectCreate("L4 label", OBJ_TEXT, 0, LabelShiftTimeC, L4);
      ObjectSetText("L4 label", " L4 ", 8, "Arial", White);
 
      ObjectCreate("L5 label", OBJ_TEXT, 0, LabelShiftTimeC, L5);
      ObjectSetText("L5 label", " L5 ", 8, "Arial", White);

      ObjectCreate("H5 line", OBJ_HLINE, 0, LineShiftTime, H5);
      ObjectSet("H5 line", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("H5 line", OBJPROP_COLOR, SpringGreen);
      ObjectSet("H5 line", OBJPROP_WIDTH, 1);

      ObjectCreate("H4 line", OBJ_HLINE, 0, LineShiftTime, H4);
      ObjectSet("H4 line", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("H4 line", OBJPROP_COLOR, SpringGreen);
      ObjectSet("H4 line", OBJPROP_WIDTH, 1);

      ObjectCreate("H3 line", OBJ_HLINE, 0, LineShiftTime, H3);
      ObjectSet("H3 line", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("H3 line", OBJPROP_COLOR, SpringGreen);
      ObjectSet("H3 line", OBJPROP_WIDTH, 2);

      ObjectCreate("L3 line", OBJ_HLINE, 0, LineShiftTime, L3);
      ObjectSet("L3 line", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("L3 line", OBJPROP_COLOR, Red);
      ObjectSet("L3 line", OBJPROP_WIDTH, 2);

      ObjectCreate("L4 line", OBJ_HLINE, 0, LineShiftTime, L4);
      ObjectSet("L4 line", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("L4 line", OBJPROP_COLOR, Red);
      ObjectSet("L4 line", OBJPROP_WIDTH, 1);

      ObjectCreate("L5 line", OBJ_HLINE, 0, LineShiftTime, L5);
      ObjectSet("L5 line", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("L5 line", OBJPROP_COLOR, Red);
      ObjectSet("L5 line", OBJPROP_WIDTH, 1);
  
   
   return(0);
}
//+---------------------------------------------------------

Comments