Download MetaTrader 5

Data output is shifted by one day

To add comments, please log in or register
mark101
85
mark101  
void OnTick()
  {
   //Code should only be executed once per day (at the end of the day)
   static datetime oldtime;
   if(oldtime!=iTime(NULL, PERIOD_D1, 0))
   {
      stronger("EURUSD");
           
      oldtime = iTime(NULL, PERIOD_D1, 0);
   }


bool stronger(string Pair)
// Function returns True if it was an up day*/
   {
      double currentBid = iClose(Pair, PERIOD_D1, 0);
      if(currentBid > iOpen(Pair, PERIOD_D1, 1))
         return(True);
      else return(False);
   }

This gives me the correct output for the day before.

There must be several things wrong because intuitively the function

would compare the Close vs Open but here it has to compare the Close 

to the Open from yesterday to deliver the correct result.


It ultimately should output data to a csv-file but as the title says it is delayed 

by one day and I don't get todays data.

whroeder1
16555
whroeder1  
mark101: here it has to compare the Close to the Open from yesterday to deliver the correct result.
      double currentBid = iClose(Pair, PERIOD_D1, 0);
      if(currentBid > iOpen(Pair, PERIOD_D1, 1))

It ultimately should output data to a csv-file

  1. You are not comparing yesterdays close vs. yesterdays open. Your are comparing the current Bid to yesterdays open. Fix your code.
  2. It's not going to output data unless you write code.
To add comments, please log in or register