The day before dayhigh und low

 

Hallo,

since weeks I have a problem with the correctly calculation of the day before dayhigh und low directly after (the first! tick) change of day.

Previously, this worked:

if (oldday != StringToTime(TimeToString(TimeCurrent(), TIME_DATE)) {    //directly the first tick after change of day

   dayhigh = iHigh(Symbol(), PERIOD_D1, 1);

   daylow = iLow(Symbol(), PERIOD_D1, 1);

   oldday = StringToTime(TimeToString(TimeCurrent(), TIME_DATE));

}

Now I always get values equal to 0.

What is wrong or who has a working code?

Thanks!

traderdoc 

 
It should still work please press F2 and download D1 historic data.
 

I think, thats not the solution.

How can I download the history at 00:00? At this time, I sleep and everything else should happen automatically. 

 

Why are you pushing time in and out of a string? The more complicated something is, the greater the likelihood of it going wrong. Just use datetime variables to check for a new day.

datetime today = iTime(Symbol(),PERIOD_D1,0);
if (oldday != today) {    //directly the first tick after change of day
   dayhigh = iHigh(Symbol(), PERIOD_D1, 1);
   daylow  = iLow(Symbol(), PERIOD_D1, 1);
   oldday  = today;
}


 

 
programmierer:

I think, thats not the solution.

How can I download the history at 00:00? At this time, I sleep and everything else should happen automatically. 

You get a zero when the data you ask for isn't available thats why you make sure history center is up to date by downloading past data.

It does not mean you have to do it at 00:00 night.

Have you tried it ?

The fact that you think it's not the solution before even trying it and thinking it has to be done at 00:00 makes me stress out.

 

Hallo @marco,

sorry, but how are the data updared at 00:00? I need this exactly after the day change and not later.


Hallo@honest,

I already tried that, which ran earlier. Now it seems that the last day is not yet available right after the day change. This is also noticable when the EA is reinstalled and I do not want it to determine the high and low on the same day, but only at the next day change. Nevertheless, it immediately jumps into the query. That is not correct.

 

traderdoc 

 
programmierer: I already tried that, which ran earlier. Now it seems that the last day is not yet available right after the day change.
Of course not. If you haven't looked at the D1 in the last 10 minutes, it's not updated. You need to handle it.
  1. either update D1 data History data and error 4066 - MQL4 forum first
  2. or, just find the previous day's start and end and get the range from the current chart.
 

Thanks, but how should I look at D1 at night?

Or how can the EA update the history automatically after the day change?
 
programmierer: Thanks, but how should I look at D1 at night? Or how can the EA update the history automatically after the day change?
I just answered that, but you couldn't be bothered to read the link provided.
 
@whroeder1,

sorry, I had not looked at the link yet. I thought it would just be a link to this error, not to your solution.


I try it this night.
Reason: