time and date

 

dear friends,

i need help with the time and date to set my script in motion... meaning - how can i differentiate between Monday and Tuesday ... and how can I translate the hours from the broker platform ?

any piece of code in this respect is greatly appreciated !


have a wonderful day ahead & thank You !

 
CB:

dear friends,

i need help with the time and date to set my script in motion... meaning - how can i differentiate between Monday and Tuesday ... and how can I translate the hours from the broker platform ?

any piece of code in this respect is greatly appreciated !


have a wonderful day ahead & thank You !

Have you seen this? In there, the use of TimeToStruct will allow you to retrieve the day information.

 
if(TimeDayOfWeek(TimeCurrent())==SUNDAY)
 {
    BuyIcecream(MaxLots);
    ExpertRemove();
 }
 
lippmaje:

looks good - you just compare with the day ? can you do the same with the hour ? how ? appreciated !

 
  1. lippmaje:
    if(TimeDayOfWeek(

    Where do you see that function in the documentation? Or the added functions
              List of MQL5 Functions - Reference on algorithmic/automated trading language for MetaTrader 5
              New MetaTrader 5 Platform beta build 1845: MQL5 functions for operations with bars and Strategy Tester improvements - Options Trading Strategies - General - MQL5 programming forum 2018.06.08

  2. CB: can you do the same with the hour ? how ?

    Perhaps Again you should read the manual.

    This is the group of functions for working with data of datetime type
              Date and Time - Reference on algorithmic/automated trading language for MetaTrader 5
  3. and Migrating from MQL4 to MQL5 - MQL5 Articles № 11

 

Yes but if you know you can help him to save his time by summarizing for him.

 
MqlDateTime currentTime;
datetime currentTime_dt=TimeCurrent(currentTime);
// now we have the 'raw' current time in currentTime_dt and the 'structured' time in currentTime struct

if(currentTime.day_of_week>=MONDAY && currentTime.day_of_week<=FRIDAY && currentTime.hour>=10 && currentTime.hour<=17)
 {
    ExpertGoToWork();
 }
Here's how to do it with a time struct, works both MQL4 and 5.
 
Mafuta Landou: Yes but if you know you can help him to save his time by summarizing for him.

Then he keeps asking the same type of trivial question, wasting everyone's time and learning nothing. It's not saving him any time.

You'll change your mind, after you answer his 25th question.

 
William Roeder:

Then he keeps asking the same type of trivial question, wasting everyone's time and learning nothing. It's not saving him any time.

You'll change your mind, after you answer his 25th question.

Support the weak That is what forum is about
 
lippmaje:
Here's how to do it with a time struct, works both MQL4 and 5.

lippmaje - great help sir. appreciated. we can close this thread. APPRECIATED SIR !

 
William Roeder:

Then he keeps asking the same type of trivial question, wasting everyone's time and learning nothing. It's not saving him any time.

You'll change your mind, after you answer his 25th question.

i have opened 3 threads for the last 3 years. i have no idea why you are so exaggerated in reaction...

Reason: