Download MetaTrader 5

How to choose the date for yesterday in mql4

To add comments, please log in or register
Post web links to other trader's signals and make profit
Mahfoud Allali
324
Mahfoud Allali 2015.12.21 09:30 
datetime ends=yesterday;
Osama Shaban
1448
Osama Shaban 2015.12.21 10:40  

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
324
Mahfoud Allali 2015.12.21 13:16  
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
3741
Xiangdong Guo 2015.12.21 14:40  

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
602
Snelle Moda 2015.12.22 11:53  

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