Download MetaTrader 5

How to choose the date for yesterday in mql4

To add comments, please log in or register
Mahfoud Allali
325
Mahfoud Allali  
datetime ends=yesterday;
Osama Shaban
1491
Osama Shaban  

This is a general question, or may be I didn't understand it clearly! ... Please make it specific or describe your case to get the right answer.

Meantime, this could help ...

I use this into my EAs for expiry period ...

datetime Expiry = D'2015.12.21 23:59';
.....
.....
.....
if(TimeCurrent()>Expiry){
   ..... 
   .....
   .....
   return(0);
}

 So, you may use same idea by changing the desired end time.

Mahfoud Allali
325
Mahfoud Allali  
Osama Shaban:

This is a general question, or may be I didn't understand it clearly! ... Please make it specific or describe your case to get the right answer.

Meantime, this could help ...

I use this into my EAs for expiry period ...

 So, you may use same idea by changing the desired end time.

thank you brother for helping
but i want to change Expiry to yesterday automatically
Xiangdong Guo
3840
Xiangdong Guo  

Potential code

    datetime yesterday = TimeCurrent() - 60 * 60 * 24;
    string time_yyyy_MM_dd = TimeToString(yesterday, TIME_DATE);
    Print("Yesterday=", StringToTime(time_yyyy_MM_dd));
Snelle Moda
606
Snelle Moda  

Other example.

// Date of yesterday
//------------------
   datetime DayTimeBars[]; // Array for time/date value.
   CopyTime(Symbol(), PERIOD_D1, 1, 1, DayTimeBars); // Copy the time/date of the previous bar/day to array.
   
   Alert("The date of yesterday = ", DayTimeBars[0]);
To add comments, please log in or register