Weekly Pivots

 
Hello.

In the online database are some pivots indicators, and some of them let you set to use local time (or GMT correction) instead broker time.

But there is no one one to calculate weekly pivots.

There are some indicators code in another forums. I´d take some code, added some deleted some etc. And what I´m posting is what I´m using right now.

But, some friends are reporting also different values according to broker server. And some friends who are calculating pivots manually are reporting big differences.

For dailies we stepped up this problem using the mentioned indicators with GMT correction or local time.

The problem is now how to make the same for weekly pivots.

IE: Let´s say you want to calculate WP from last week Monday London Open to current week Monday London open. Or from last 5PM NY Friday to today 5PM NY Friday.

Most weekly PP indicators use TimeDayOfWeek variable to calculate the open and the close of the week. But this, makes you dependat of your broker server time.

Is there any way to solve this problem?

Thanks.

//---- buffers
double PBuffer[];
double S1Buffer[];
double R1Buffer[];
double S2Buffer[];
double R2Buffer[];
double S3Buffer[];
double R3Buffer[];
string Pivot="WeeklyPivotPoint",Sup1="W_S 1", Res1="W_R 1";
string Sup2="W_S 2", Res2="W_R 2", Sup3="W_S 3", Res3="W_R 3";
double P,S1,R1,S2,R2,S3,R3;
double last_week_high, last_week_low, this_week_open, last_week_close;
datetime LabelShiftTime;
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
 
   ObjectDelete("WeeklyPivot");
   ObjectDelete("WSup1");
   ObjectDelete("WRes1");
   ObjectDelete("WSup2");
   ObjectDelete("WRes2");
   ObjectDelete("WSup3");
   ObjectDelete("WRes3");   
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
 
 
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,EMPTY);
   SetIndexStyle(1,DRAW_LINE,EMPTY);
   SetIndexStyle(2,DRAW_LINE,EMPTY);
   SetIndexStyle(3,DRAW_LINE,EMPTY);
   SetIndexStyle(4,DRAW_LINE,EMPTY);
   SetIndexStyle(5,DRAW_LINE,EMPTY);
   SetIndexStyle(6,DRAW_LINE,EMPTY);
   SetIndexBuffer(0,PBuffer);
   SetIndexBuffer(1,S1Buffer);
   SetIndexBuffer(2,R1Buffer);
   SetIndexBuffer(3,S2Buffer);
   SetIndexBuffer(4,R2Buffer);
   SetIndexBuffer(5,S3Buffer);
   SetIndexBuffer(6,R3Buffer);
 
 
//---- name for DataWindow and indicator subwindow label
   short_name="Pivot Point Weekly";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
 
//----
   SetIndexDrawBegin(0,1);
//----
 
 
//----
   return(0);
  }
 
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
 
  {
   int counted_bars=IndicatorCounted();
 
   int limit, i;
//---- indicator calculation
if (counted_bars==0)
{
   if(Period() > 1440)
   {
   Print("Error - Chart period is greater than 1 day.");
   return(-1); // then exit
   }
   
}
   if(counted_bars<0) return(-1);
 
   limit=(Bars-counted_bars)-1;
 
 
for (i=limit; i>=0;i--)
{ 
 
 
   // Monday
    if ( 1 == TimeDayOfWeek(Time[i]) && 1 != TimeDayOfWeek(Time[i+1]) )
    {
        last_week_close = Close[i+1];
        this_week_open = Close[i+2];
 
        // WeeklyPivot
    P = (last_week_high + last_week_low + last_week_close+this_week_open) / 4;
 
   R1 = (2*P)-last_week_low;
   S1 = (2*P)-last_week_high;
   R2 = P+(last_week_high - last_week_low);
   S2 = P-(last_week_high - last_week_low);
   R3 = (2*P)+(last_week_high-(2*last_week_low));
   S3 = (2*P)-((2* last_week_high)-last_week_low); 
  
   last_week_low=Low[i]; last_week_high=High[i];
 
 
}   
    
    last_week_high = MathMax(last_week_high, High[i]);
    last_week_low = MathMin(last_week_low, Low[i]);   
    
    PBuffer[i]=P;
    S1Buffer[i]=S1;
    R1Buffer[i]=R1;
    S2Buffer[i]=S2;
    R2Buffer[i]=R2;
    S3Buffer[i]=S3;
    R3Buffer[i]=R3;
 
}
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Linuxser wrote >>
Hello.

In the online database are some pivots indicators, and some of them let you set to use local time (or GMT correction) instead broker time.

But there is no one one to calculate weekly pivots.

There are some indicators code in another forums. I´d take some code, added some deleted some etc. And what I´m posting is what I´m using right now.

But, some friends are reporting also different values according to broker server. And some friends who are calculating pivots manually are reporting big differences.

For dailies we stepped up this problem using the mentioned indicators with GMT correction or local time.

The problem is now how to make the same for weekly pivots.

IE: Let´s say you want to calculate WP from last week Monday London Open to current week Monday London open. Or from last 5PM NY Friday to today 5PM NY Friday.

Most weekly PP indicators use TimeDayOfWeek variable to calculate the open and the close of the week. But this, makes you dependat of your broker server time.

Is there any way to solve this problem?

Thanks.

I think the Weekly pivot value is not correct calculated with this indicator.

Reason: