Download MetaTrader 5

Programming Request: Help with Weekly Pivot With Unique Time Start

To add comments, please log in or register
Josh
13
Josh  

Hi Guys and Gals,

Trying to write a weekly pivot that starts at 2 am Monday and ends 1:59.59 Monday.

This is because my broker's servers are in Cypress, 2 hours ahead of GMT.

How do I retrieve the final bid price value of 1:59 and 59 seconds on Monday only and plug it into the pivot point formula as last weeks close (W_yesterday_close)?

How do I retrieve the initial bid price value of 2:00 and 00 seconds on Monday only and plug it into the pivot point formula as this weeks open (W_today_open)?

All my variables at the beginning are stated as "double" and =0 initially.

If anyone could help it would be much appreciated.

Thanks


ArrayCopyRates(W_rates_d1, Symbol(), 10080);

W_yesterday_open = W_rates_d1[1][1];
W_yesterday_high = W_rates_d1[1][3];
W_yesterday_low = W_rates_d1[1][2];
W_day_high = W_rates_d1[0][3];
W_day_low = W_rates_d1[0][2];

if(DayOfWeek()==1)
{if(Hour()==1)
{if(Minute()==59)
{if(Seconds()==59)
{ W_yesterday_close = MarketInfo(Symbol(),MODE_BID);
}}}} else W_yesterday_close = W_yesterday_close;


if(DayOfWeek()==1)
{if(Hour()==2)
{if(Minute()==0)
{if(Seconds()==0)
{ W_today_open = MarketInfo(Symbol(),MODE_BID);
}}}} else W_today_open = W_today_open;

if(DayOfWeek()>1)
{W_yesterday_close = W_yesterday_close;
W_today_open = W_today_open;
}
if(DayOfWeek()==0)
{W_yesterday_close = W_yesterday_close;
W_today_open = W_today_open;
}

//---- Calculate Pivots

W_D = (W_day_high - W_day_low);
W_Q = (W_yesterday_high - W_yesterday_low);
W_P = (W_yesterday_high + W_yesterday_low + W_yesterday_close + W_today_open) / 4;
W_R1 = (2*W_P)-W_yesterday_low;
W_S1 = (2*W_P)-W_yesterday_high;
W_R2 = W_P+(W_yesterday_high - W_yesterday_low);
W_S2 = W_P-(W_yesterday_high - W_yesterday_low);

To add comments, please log in or register