pimpspit-weekly-pivot

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

The Pimpology Monthly Pivot is a specialized technical analysis tool designed to project significant price levels based on historical weekly market data. Its primary purpose is to help traders identify potential support and resistance zones where the price might react, stall, or reverse.

Core Logic & Functionality

The script operates by analyzing the price action of the Weekly timeframe. Even if you are viewing a smaller chart (like a 15-minute or 1-hour chart), the tool "looks ahead" at the previous week's performance to calculate key milestones for the current period.

1. Data Collection

The tool starts by gathering three specific data points from the completed weekly candle:

  • The highest price reached (High)
  • The lowest price reached (Low)
  • The closing price (Close)

2. The Pivot Point (The Anchor)

Using these three values, the script calculates a central "Pivot Point." This is essentially the equilibrium price of the previous week. In the visual interface, this is highlighted as the primary reference line. It serves as the "center" from which all other levels are derived.

3. Resistance and Support Levels

Once the central Pivot Point is established, the script mathematically projects three distinct levels above it and three levels below it:

  • Resistance Levels (R1, R2, R3): These represent ceiling zones. They indicate areas where buying pressure might exhaust, potentially causing the price to drop back down.
  • Support Levels (S1, S2, S3): These represent floor zones. They indicate areas where selling pressure might weaken, potentially causing the price to bounce back up.

4. Visual Representation

To ensure clarity for the user, the script performs several automated tasks on the chart:

  • Dynamic Drawing: It automatically plots continuous lines for all seven levels (the Pivot, three Resistances, and three Supports).
  • Labeling: It places specific text labels (such as "wp", "wr1", "ws1", etc.) next to the price points so the trader can instantly identify which level is which.
  • Automatic Updates: The script is designed to refresh these calculations automatically. As new time periods progress, it updates the positions of the lines and labels to reflect the most recent historical data.

Summary for the Trader

Think of this tool as a "map" of where the market has shown strength or weakness in the past. By calculating these levels based on weekly data, it provides you with a set of predetermined boundaries that help you decide where to enter, exit, or manage your trades more effectively.

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
8 Views
0 Downloads
0 Favorites
pimpspit-weekly-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 Olive
#property indicator_color2 Gray
#property indicator_color3 Gray
#property indicator_color4 Gray
#property indicator_color5 Gray
#property indicator_color6 Gray
#property indicator_color7 Gray
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("WeekP");
   ObjectDelete("WeekR1");
   ObjectDelete("WeekR2");
   ObjectDelete("WeekR3");
   ObjectDelete("WeekS1");
   ObjectDelete("WeekS2");
   ObjectDelete("WeekS3");
   ObjectDelete("txtWeekP");
   ObjectDelete("txtWeekR1");
   ObjectDelete("txtWeekR2");
   ObjectDelete("txtWeekR3");
   ObjectDelete("txtWeekS1");
   ObjectDelete("txtWeekS2");
   ObjectDelete("txtWeekS3");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i, Weeki, 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--)
     {
       Weeki = iBarShift(Symbol(), PERIOD_W1, Time[i], false);
       Q = (iHigh(Symbol(), PERIOD_W1,Weeki + 1) - iLow(Symbol(), PERIOD_W1, Weeki + 1));
       PP = (iHigh(Symbol(), PERIOD_W1, Weeki + 1) + iLow(Symbol(), PERIOD_W1, Weeki + 1) + iClose(Symbol(), PERIOD_W1, Weeki + 1)) / 3;    
       DR1 = (2*PP)-iLow(Symbol(), PERIOD_W1, Weeki + 1);
       DS1 = (2*PP)-iHigh(Symbol(), PERIOD_W1,Weeki + 1);
       DR2 = PP+(iHigh(Symbol(), PERIOD_W1,Weeki + 1) - iLow(Symbol(), PERIOD_W1, Weeki + 1));
       DS2 = PP-(iHigh(Symbol(), PERIOD_W1,Weeki + 1) - iLow(Symbol(), PERIOD_W1, Weeki + 1));
       DR3 = (2*PP)+(iHigh(Symbol(), PERIOD_W1,Weeki + 1)-(2*iLow(Symbol(), PERIOD_W1, Weeki + 1)));
       DS3 = (2*PP)-((2* iHigh(Symbol(), PERIOD_W1,Weeki + 1))-iLow(Symbol(), PERIOD_W1, Weeki + 1));
       P1Buffer[i] = PP;
       SetPrice("WeekP", Time[i], PP, indicator_color1);
       SetText("txtWeekP", "wp", Time[i], PP, indicator_color1);
       P2Buffer[i] = DR1;
       SetPrice("WeekR1", Time[i], DR1, indicator_color4);
       SetText("txtWeekR1", "wr1", Time[i], DR1, indicator_color4);
       P3Buffer[i] = DS1;
       SetPrice("WeekS1", Time[i], DS1, indicator_color4);
       SetText("txtWeekS1", "ws1", Time[i], DS1, indicator_color4);
       P4Buffer[i] = DR2;
       SetPrice("WeekR2", Time[i], DR2, indicator_color4);
       SetText("txtWeekR2", "wr2", Time[i], DR2, indicator_color4);
       P5Buffer[i] = DS2;
       SetPrice("WeekS2", Time[i], DS2, indicator_color4);
       SetText("txtWeekS2", "ws2", Time[i], DS2, indicator_color4);
       P6Buffer[i] = DR3;
       SetPrice("WeekR3", Time[i], DR3, indicator_color4);
       SetText("txtWeekR3", "wr3", Time[i], DR3, indicator_color4);
       P7Buffer[i] = DS3;
       SetPrice("WeekS3", Time[i], DS3, indicator_color4);
       SetText("txtWeekS3", "ws3", 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