YearlyPivot_001

Download script
Author: Copyright � 2006, Profitrader.
YearlyPivot_001

This technical tool is designed to provide traders with a clear visual roadmap of significant price levels based on yearly market activity. Instead of focusing on short-term fluctuations, it identifies "Pivot Points"—key areas where the market often shifts direction or faces resistance—based on the previous year's performance.

Core Functionality

The script automatically calculates and plots seven distinct horizontal price levels on your trading chart. These levels act as milestones that help identify where price might encounter "floors" (Support) or "ceilings" (Resistance).

How the Logic Works

The indicator operates by analyzing historical price data to establish a baseline for the current year. Here is the step-by-step logic it follows:

  • Data Collection: The tool scans the market history to identify the highest price reached, the lowest price reached, and the closing price of the previous year. It also incorporates the opening price of the current year.
  • The Pivot Point: Using these three historical benchmarks (High, Low, and Close), the script calculates a central "Yearly Pivot Point." This represents the equilibrium value for the current year’s price action.
  • Support and Resistance Mapping: From that central Pivot Point, the script derives three layers of support and resistance:
    • Level 1 (Primary): These are the immediate areas of interest closest to the pivot.
    • Level 2 (Secondary): These represent broader zones of market sentiment.
    • Level 3 (Tertiary): These are "extreme" levels, identifying significant historical boundaries that the price may reach during periods of high volatility.
  • Dynamic Updating: The script is designed to automatically detect the transition between years. When the calendar flips, it refreshes its calculations to ensure the lines on your chart remain accurate and relevant to the new year's data.

Key Features for the User

  • Automated Calculation: You do not need to manually calculate complex formulas; the script handles all the math behind the scenes.
  • Timeframe Compatibility: The tool is optimized for higher timeframes (specifically designed to function when looking at weekly charts or higher), making it ideal for long-term investors and swing traders.
  • Visual Clarity: It draws clear, labeled lines on your chart, allowing you to see exactly where the "Yearly Support" and "Yearly Resistance" levels sit relative to the current market price.

By using this logic, a trader can better anticipate potential trend reversals or breakthroughs by watching how the price interacts with these pre-calculated yearly boundaries.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
YearlyPivot_001
//+------------------------------------------------------------------+
//|                                                     Yearly Pivot |
//|                                    Copyright © 2006, Profitrader |
//|                                    Coded/Verified by Profitrader |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Profitrader."
#property link      "profitrader@inbox.ru"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Orchid
#property indicator_color2 SlateBlue
#property indicator_color3 IndianRed
#property indicator_color4 SlateBlue
#property indicator_color5 IndianRed
#property indicator_color6 DarkOliveGreen
#property indicator_color7 DarkOliveGreen
//---- buffers
double PBuffer[];
double S1Buffer[];
double R1Buffer[];
double S2Buffer[];
double R2Buffer[];
double S3Buffer[];
double R3Buffer[];

double P,S1,R1,S2,R2,S3,R3,last_year_high,last_year_low,last_year_close,this_year_open;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0,PBuffer);
   SetIndexBuffer(1,S1Buffer);
   SetIndexBuffer(2,R1Buffer);
   SetIndexBuffer(3,S2Buffer);
   SetIndexBuffer(4,R2Buffer);
   SetIndexBuffer(5,S3Buffer);
   SetIndexBuffer(6,R3Buffer);
   SetIndexStyle(0,DRAW_LINE,4,1);
   SetIndexStyle(1,DRAW_LINE,4,1);
   SetIndexStyle(2,DRAW_LINE,4,1);
   SetIndexStyle(3,DRAW_LINE,4,1);
   SetIndexStyle(4,DRAW_LINE,4,1);
   SetIndexStyle(5,DRAW_LINE,4,1);
   SetIndexStyle(6,DRAW_LINE,4,1);
   SetIndexLabel(0,"Yearly Pivot Point");
   SetIndexLabel(1,"Yearly Support 1");
   SetIndexLabel(2,"Yearly Resistant 1");
   SetIndexLabel(3,"Yearly Support 2");
   SetIndexLabel(4,"Yearly Resistant 2");
   SetIndexLabel(5,"Yearly Support 3");
   SetIndexLabel(6,"Yearly Resistant 3");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("Yearly Pivot");
   ObjectDelete("Yearly Sup1");
   ObjectDelete("Yearly Res1");
   ObjectDelete("Yearly Sup2");
   ObjectDelete("Yearly Res2");
   ObjectDelete("Yearly Sup3");
   ObjectDelete("Yearly Res3");   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;  
   int limit=Bars-counted_bars;
   
   if(Period()>PERIOD_W1) return(-1);
   if(counted_bars==0)
     {
      ObjectCreate("Yearly Pivot",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly Pivot","                            Yearly Pivot Point",10,"Arial",Salmon);
      ObjectCreate("Yearly Sup1",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly Sup1","        yS 1",10,"Arial",Salmon);
      ObjectCreate("Yearly Res1",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly Res1","        yR 1",10,"Arial",Salmon);
      ObjectCreate("Yearly Sup2",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly Sup2","        yS 2",10,"Arial",Salmon);
      ObjectCreate("Yearly Res2",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly Res2","        yR 2",10,"Arial",Salmon);
      ObjectCreate("Yearly Sup3",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly Sup3","        yS 3",10,"Arial",Salmon);
      ObjectCreate("Yearly Res3",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly Res3","        yR 3",10,"Arial",Salmon);
     }
   for(i=limit-1; i>=0; i--)
      {
       // 1sts Days of Year
	    if(TimeDayOfYear(Time[i])<=10 && TimeDayOfYear(Time[i+1])>=355)
	      {
		    last_year_close=Close[i+1];
		    this_year_open=Open[i];		
		    P=(last_year_high+last_year_low+last_year_close+this_year_open)/4;
          R1=(2*P)-last_year_low;
          S1=(2*P)-last_year_high;
          R2=P+(last_year_high-last_year_low);
          S2=P-(last_year_high-last_year_low);
          R3=(2*P)+(last_year_high-(2*last_year_low));
          S3=(2*P)-((2*last_year_high)-last_year_low); 
        	 ObjectMove("Yearly Pivot",0,Time[i],P);
          ObjectMove("Yearly Sup1",0,Time[i],S1);
          ObjectMove("Yearly Res1",0,Time[i],R1);
          ObjectMove("Yearly Sup2",0,Time[i],S2);
          ObjectMove("Yearly Res2",0,Time[i],R2);
          ObjectMove("Yearly Sup3",0,Time[i],S3);
          ObjectMove("Yearly Res3",0,Time[i],R3);
          last_year_low=Low[i];
          last_year_high=High[i];
         }       
       last_year_low=MathMin(last_year_low,Low[i]);   
       last_year_high=MathMax(last_year_high,High[i]);
       PBuffer[i]=P;
       S1Buffer[i]=S1;
       R1Buffer[i]=R1;
       S2Buffer[i]=S2;
       R2Buffer[i]=R2;
       S3Buffer[i]=S3;
       R3Buffer[i]=R3;
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments