pimpspit-monthly-pivot
Download scriptThis tool is designed to provide traders with a comprehensive visual map of significant monthly price levels. By analyzing historical monthly data, it automatically calculates and plots several key "Pivot Points"—mathematical benchmarks that help identify potential support and resistance zones in the currency or asset market.
Core Functionality
The script operates by looking back at the preceding month's performance. It specifically takes the highest price reached, the lowest price reached, and the closing price of that completed month to calculate a series of projected levels for the current month.
These levels are divided into three primary categories:
- The Monthly Pivot Point (PP): This is the central equilibrium of the previous month's price action. It serves as the "anchor" or the main balance point for the current period.
- Primary Support and Resistance (S1, R1, S2, R2): These are calculated based on the distance between the pivot point and the extremes of the previous month. They represent the most immediate areas where price may stall, reverse, or find steady ground.
- Secondary Support and Resistance (S3, R3): These are deeper, extended levels. They are calculated using a more complex multiplier of the previous month's range, helping traders identify major "outer" boundaries where significant market reactions often occur.
Visual Presentation
To ensure the data is easy to read on a live chart, the script performs several automated tasks:
- Dynamic Plotting: It draws seven distinct lines on your chart representing all the calculated levels (PP, R1, S1, R2, S2, R3, and S3).
- Automated Labeling: The script doesn't just draw lines; it places clear text markers (such as "mp" for Monthly Pivot, "mr1" for Monthly Resistance 1, etc.) at the correct price points. This allows you to identify each level instantly without guesswork.
- Visual Markers: In addition to the lines and text, the script places small arrow icons at these levels to highlight specific price coordinates that are of high interest.
- Clean Organization: The script includes a "cleanup" feature that ensures old or unnecessary objects are removed from your chart, keeping your trading workspace organized and professional.
Summary for Traders
Instead of manually calculating complex math every time the month changes, this script automates the process. It provides a "road map" of where the market is likely to face pressure (Resistance) or find buyers (Support) based on the previous month's behavior, allowing you to make more informed decisions about your entry and exit points.
//+-------------------------------------------------------------------------+
//| 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 DarkGreen
#property indicator_color2 DarkGray
#property indicator_color3 DarkGray
#property indicator_color4 DarkGray
#property indicator_color5 DarkGray
#property indicator_color6 DarkGray
#property indicator_color7 DarkGray
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("MonthP");
ObjectDelete("MonthR1");
ObjectDelete("MonthR2");
ObjectDelete("MonthR3");
ObjectDelete("MonthS1");
ObjectDelete("MonthS2");
ObjectDelete("MonthS3");
ObjectDelete("txtMonthP");
ObjectDelete("txtMonthR1");
ObjectDelete("txtMonthR2");
ObjectDelete("txtMonthR3");
ObjectDelete("txtMonthS1");
ObjectDelete("txtMonthS2");
ObjectDelete("txtMonthS3");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, Monthi, 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--)
{
Monthi = iBarShift(Symbol(), PERIOD_MN1, Time[i], false);
Q = (iHigh(Symbol(), PERIOD_MN1,Monthi + 1) - iLow(Symbol(), PERIOD_MN1, Monthi + 1));
PP = (iHigh(Symbol(), PERIOD_MN1, Monthi + 1) + iLow(Symbol(), PERIOD_MN1, Monthi + 1) + iClose(Symbol(), PERIOD_MN1, Monthi + 1)) / 3;
DR1 = (2*PP)-iLow(Symbol(), PERIOD_MN1, Monthi + 1);
DS1 = (2*PP)-iHigh(Symbol(), PERIOD_MN1,Monthi + 1);
DR2 = PP+(iHigh(Symbol(), PERIOD_MN1,Monthi + 1) - iLow(Symbol(), PERIOD_MN1, Monthi + 1));
DS2 = PP-(iHigh(Symbol(), PERIOD_MN1,Monthi + 1) - iLow(Symbol(), PERIOD_MN1, Monthi + 1));
DR3 = (2*PP)+(iHigh(Symbol(), PERIOD_MN1,Monthi + 1)-(2*iLow(Symbol(), PERIOD_MN1, Monthi + 1)));
DS3 = (2*PP)-((2*iHigh(Symbol(), PERIOD_MN1,Monthi + 1))-iLow(Symbol(), PERIOD_MN1, Monthi + 1));
P1Buffer[i] = PP;
SetPrice("MonthP", Time[i], PP, indicator_color1);
SetText("txtMonthP", "mp", Time[i], PP, indicator_color1);
P2Buffer[i] = DR1;
SetPrice("MonthR1", Time[i], DR1, indicator_color4);
SetText("txtMonthR1", "mr1", Time[i], DR1, indicator_color4);
P3Buffer[i] = DS1;
SetPrice("MonthS1", Time[i], DS1, indicator_color4);
SetText("txtMonthS1", "ms1", Time[i], DS1, indicator_color4);
P4Buffer[i] = DR2;
SetPrice("MonthR2", Time[i], DR2, indicator_color4);
SetText("txtMonthR2", "mr2", Time[i], DR2, indicator_color4);
P5Buffer[i] = DS2;
SetPrice("MonthS2", Time[i], DS2, indicator_color4);
SetText("txtMonthS2", "ms2", Time[i], DS2, indicator_color4);
P6Buffer[i] = DR3;
SetPrice("MonthR3", Time[i], DR3, indicator_color4);
SetText("txtMonthR3", "mr3", Time[i], DR3, indicator_color4);
P7Buffer[i] = DS3;
SetPrice("MonthS3", Time[i], DS3, indicator_color4);
SetText("txtMonthS3", "ms3", 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