Download MetaTrader 5
To add comments, please log in or register
Are you used to trading from your smartphone? Mobile version of MetaTrader 5 will suit you best!
dalidyh
7
dalidyh 2015.08.17 10:16 

Hey guys,

So I made an EA and in the code it counted the weeks it was all working well but then I saved over the EA accidentally with an earlier version and I can't seem to figure out how I coded the week counter so I'm in need of some help.
On the monday I want it to plus one onto "int week" then when "week" gets 5  it - 4 so its back at week one.

Some code off the top of my head how I think it should look like.

Thanks for the help I'm just getting into this. 

extern int tradeweek = x

int week = 1

if(DayOfWeek() == 1)

{

 for(week >4; week++)

{

Alert("Week " + week); 

if(week == 5)

{

 week - 4;

Alert("Week " + week);  

}

}

if(week == tradeweek)

//Continue EA 

whroeder1
13590
whroeder1 2015.08.17 10:47  
dalidyh: On the monday I want it to plus one onto "int week" then when "week" gets 5  it - 4 so its back at week one.
  1. int week = iBarShift(NULL, PERIOD_W1, 0) % 4 + 1; // 1 .. 4
  2. Don't assume that the week starts on Monday; depending on your broker's time zone, there can be a 1-2 hour Sunday bar (GMT) or 6pm - midnight (ET.) Don't assume that the week ends on Friday; Wellington/Singapore TZ's go into early Saturday.
/
To add comments, please log in or register