newbee question - the iOpen function

 

Hi, I'm trying to work out daily, weekly, monthly and yearly opening prices.

I've just put very simple code together, however when I run this the weekly and monthly prices do not at all match up to what I'd expect.

I have attached a copy of the journal, and you'll see that a new weekly opening price is opening up on a Thursday... not sure why. The monthy opening is on the 23rd of the month...?

Please look at the rows with comments cos I've specifically marked them in to try and make this easier to detect.

My thinking is that:

1) it is something to do with the timezones and I'm not aware of how metatrader works

2) I have a data issue

3) Also, re calculating a yearly opening price, couldn't find the period. Does that mean it can't be done?

Can anybody please explain to me what I am doing wrong?

Ta

int start()
  {
//----
   double m = iOpen(NULL, PERIOD_MN1, 0);
   double w = iOpen(NULL, PERIOD_W1, 0);
   double d = iOpen(NULL, PERIOD_D1, 0);

   Print("Monthly open price is ",m," and Weekly open price is ",w, " and Daily open price is",d);

//----
   return(0);
  }

Date and Time Journal
2012.02.26 14:00:40 2011.09.23 09:33 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459
2012.02.26 14:00:39 2011.09.23 03:30 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459
2012.02.26 14:00:39 2011.09.23 03:30 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459
2012.02.26 14:00:39 2011.09.23 03:30 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459
2012.02.26 14:00:39 2011.09.23 03:30 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459
2012.02.26 14:00:39 2011.09.23 03:30 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459
2012.02.26 14:00:39 2011.09.23 03:30 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459
2012.02.26 14:00:39 2011.09.23 03:30 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459
2012.02.26 14:00:39 2011.09.23 03:30 LineTest EURUSD,H4: Monthly open price is 1.3459 and Weekly open price is 1.3571 and Daily open price is1.3459 This journal shows a monthly price change, however it's not the end of the month?
2012.02.26 14:00:38 2011.09.22 21:32 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:38 2011.09.22 21:32 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:38 2011.09.22 21:32 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:38 2011.09.22 21:32 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:38 2011.09.22 21:32 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:38 2011.09.22 21:32 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571

Date and Time Journal
2012.02.26 14:00:33 2011.09.22 10:03 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:32 2011.09.22 03:57 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:32 2011.09.22 03:57 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:32 2011.09.22 03:57 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:32 2011.09.22 03:57 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:32 2011.09.22 03:57 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:32 2011.09.22 03:57 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:32 2011.09.22 03:57 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571
2012.02.26 14:00:32 2011.09.22 03:57 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3571 and Daily open price is1.3571 Weekly open price changes here, but this is not the start of a week.
2012.02.26 14:00:31 2011.09.21 23:07 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3752 and Daily open price is1.3698
2012.02.26 14:00:31 2011.09.21 23:07 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3752 and Daily open price is1.3698
2012.02.26 14:00:31 2011.09.21 23:07 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3752 and Daily open price is1.3698
2012.02.26 14:00:31 2011.09.21 23:07 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3752 and Daily open price is1.3698
2012.02.26 14:00:31 2011.09.21 23:07 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3752 and Daily open price is1.3698
2012.02.26 14:00:31 2011.09.21 23:07 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3752 and Daily open price is1.3698
2012.02.26 14:00:31 2011.09.21 23:07 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3752 and Daily open price is1.3698
2012.02.26 14:00:31 2011.09.21 23:07 LineTest EURUSD,H4: Monthly open price is 1.4441 and Weekly open price is 1.3752 and Daily open price is1.3698
 

What you are doing seems very reasonable to me. If you have not already done so I would change the chart timeframe to each of D1, W1 and MN1 in turn and do a right mouse click, refresh, to make sure your data is up to date. A chart which is not open does not automatically get updated.

There is a trick to getting another chart to update using ArrayCopyRates in an old thread.

Reason: