pimpspit-daily-pivot

Download script
Author: No copyright, use as you wish. FX Pimp & Spitfire_412
pimpspit-daily-pivot

The Pimpology Monthly Pivot is a technical analysis tool designed to project key price levels on a trading chart. It automatically calculates specific support and resistance zones based on previous market data, helping traders identify potential turning points or "ceilings" and "floors" in price action.

Core Logic and Functionality

The script operates by analyzing the daily price movement of a financial instrument to determine three primary components for every trading day:

1. The Pivot Point (PP) This is the central reference line. The script calculates this by taking the average of three specific data points from the previous day's trading session: the high price, the low price, and the closing price. This "central" figure serves as the baseline for the rest of the calculations.

2. Resistance Levels (R1, R2, R3) The script identifies three different "upper boundaries" where price might face selling pressure:

  • R1 & S1: These are the immediate support and resistance levels calculated using the relationship between the Pivot Point and the previous day's extremes.
  • R2 & S2: These represent a secondary range, projecting further out based on the difference between the previous day's high and low.
  • R3 & S3: These serve as "deep" levels, providing a wider perspective of where extreme price action might eventually stall or reverse.

3. Automated Visual Mapping Rather than just calculating numbers in the background, the script actively manages your visual workspace:

  • Dynamic Plotting: It draws lines across your chart to represent these seven specific price levels (Pivot, 3 Resists, and 3 Supports).
  • Labeling: It automatically places text identifiers (such as "dr1", "ds2", etc.) next to each level so you can instantly distinguish between them.
  • Object Management: The script is designed to be clean; it creates these visual elements as the chart updates and ensures they are properly organized, allowing for a streamlined view of the market's structural boundaries.

Summary for the User

Essentially, this tool takes the complex math of "Pivot Point Theory" and automates it. Instead of manually calculating where the market might stall based on yesterday's data, the script draws these levels for you in real-time, providing a clear roadmap of daily price targets and structural boundaries.

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
pimpspit-daily-pivot
//+-------------------------------------------------------------------------+
//|                                                 Pimpology Monthly Pivot |
//|                   No copyright, use as you wish.  FX Pimp & Spitfire_412|
//| http://www.forex-tsd.com/general-discussion/15143-school-pimpology.html |
//+-------------------------------------------------------------------------+
#property copyright "No copyright, use as you wish.  FX Pimp & Spitfire_412"
#property link      "http://www.forex-tsd.com/general-discussion/15143-school-pimpology.html"
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightGray
#property indicator_color3 LightGray
#property indicator_color4 LightGray
#property indicator_color5 LightGray
#property indicator_color6 LightGray
#property indicator_color7 LightGray
double P1Buffer[];
double P2Buffer[];
double P3Buffer[];
double P4Buffer[];
double P5Buffer[];
double P6Buffer[];
double P7Buffer[];
double PP, Q, DR1, DS1, DR2, DS2, DR3, DS3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0, P1Buffer);
   SetIndexBuffer(1, P2Buffer);
   SetIndexBuffer(2, P3Buffer);
   SetIndexBuffer(3, P4Buffer);
   SetIndexBuffer(4, P5Buffer);
   SetIndexBuffer(5, P6Buffer);
   SetIndexBuffer(6, P7Buffer);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 3);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 1);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("DayP");
   ObjectDelete("DayR1");
   ObjectDelete("DayR2");
   ObjectDelete("DayR3");
   ObjectDelete("DayS1");
   ObjectDelete("DayS2");
   ObjectDelete("DayS3");
   ObjectDelete("txtDayP");
   ObjectDelete("txtDayR1");
   ObjectDelete("txtDayR2");
   ObjectDelete("txtDayR3");
   ObjectDelete("txtDayS1");
   ObjectDelete("txtDayS2");
   ObjectDelete("txtDayS3");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i, dayi, counted_bars = IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;  
   int limit = Bars - counted_bars;
   for(i = limit - 1; i >= 0; i--)
     {
       dayi = iBarShift(Symbol(), PERIOD_D1, Time[i], false);
       Q = (iHigh(Symbol(), PERIOD_D1,dayi + 1) - iLow(Symbol(), PERIOD_D1, dayi + 1));
       PP = (iHigh(Symbol(), PERIOD_D1, dayi + 1) + iLow(Symbol(), PERIOD_D1, dayi + 1) + iClose(Symbol(), PERIOD_D1, dayi + 1)) / 3;    
       DR1 = (2*PP)-iLow(Symbol(), PERIOD_D1, dayi + 1);
       DS1 = (2*PP)-iHigh(Symbol(), PERIOD_D1,dayi + 1);
       DR2 = PP+(iHigh(Symbol(), PERIOD_D1,dayi + 1) - iLow(Symbol(), PERIOD_D1, dayi + 1));
       DS2 = PP-(iHigh(Symbol(), PERIOD_D1,dayi + 1) - iLow(Symbol(), PERIOD_D1, dayi + 1));
       DR3 = (2*PP)+(iHigh(Symbol(), PERIOD_D1,dayi + 1)-(2*iLow(Symbol(), PERIOD_D1, dayi + 1)));
       DS3 = (2*PP)-((2* iHigh(Symbol(), PERIOD_D1,dayi + 1))-iLow(Symbol(), PERIOD_D1, dayi + 1));
       P1Buffer[i] = PP;
       SetPrice("DayP", Time[i], PP, indicator_color1);
       SetText("txtDayP", "dp", Time[i], PP, indicator_color1);
       P2Buffer[i] = DR1;
       SetPrice("DayR1", Time[i], DR1, indicator_color4);
       SetText("txtDayR1", "dr1", Time[i], DR1, indicator_color4);
       P3Buffer[i] = DS1;
       SetPrice("DayS1", Time[i], DS1, indicator_color4);
       SetText("txtDayS1", "ds1", Time[i], DS1, indicator_color4);
       P4Buffer[i] = DR2;
       SetPrice("DayR2", Time[i], DR2, indicator_color4);
       SetText("txtDayR2", "dr2", Time[i], DR2, indicator_color4);
       P5Buffer[i] = DS2;
       SetPrice("DayS2", Time[i], DS2, indicator_color4);
       SetText("txtDayS2", "ds2", Time[i], DS2, indicator_color4);
       P6Buffer[i] = DR3;
       SetPrice("DayR3", Time[i], DR3, indicator_color4);
       SetText("txtDayR3", "dr3", Time[i], DR3, indicator_color4);
       P7Buffer[i] = DS3;
       SetPrice("DayS3", Time[i], DS3, indicator_color4);
       SetText("txtDayS3", "ds3", Time[i], DS3, indicator_color4);
    }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetPrice(string name, datetime Tm, double Prc, color clr)
  {
   if(ObjectFind(name) == -1)
     {
       ObjectCreate(name, OBJ_ARROW, 0, Tm, Prc);
       ObjectSet(name, OBJPROP_COLOR, clr);
       ObjectSet(name, OBJPROP_WIDTH, 1);
       ObjectSet(name, OBJPROP_ARROWCODE, 4);
     }
   else
     {
       ObjectSet(name, OBJPROP_TIME1, Tm);
       ObjectSet(name, OBJPROP_PRICE1, Prc);
       ObjectSet(name, OBJPROP_COLOR, clr);
       ObjectSet(name, OBJPROP_WIDTH, 1);
       ObjectSet(name, OBJPROP_ARROWCODE, 4);
     } 
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetText(string name, string txt, datetime Tm, double Prc, color clr)
  {
   if(ObjectFind(name) == -1)
     {
       ObjectCreate(name, OBJ_TEXT, 0, 0, 0);
       ObjectSetText(name, txt, 8, "Times New Roman", clr);
     }
   else
     {
       ObjectSet(name, OBJPROP_TIME1, Tm);
       ObjectSet(name, OBJPROP_PRICE1, Prc);
       ObjectSetText(name, txt, 8, "Times New Roman", clr);
     } 
  }
//+------------------------------------------------------------------+

Comments