How can I get hour and minute from market watch?

To add comments, please log in or register
moslemS
43
moslemS  

Hello

How can I get and display the hour and minute from market watch in mql5 ? Display hours and minutes individually and together

thank you

Petr Nosek
1292
Petr Nosek  
moslemS:

Hello

How can I get and display the hour and minute from market watch in mql5 ? Display hours and minutes individually and together

thank you

Use function: datetime  TimeCurrent( MqlDateTime&  dt_struct) and then dt_struct.hour and dt_struct.min
moslemS
43
moslemS  
Petr Nosek:
Use function: datetime  TimeCurrent( MqlDateTime&  dt_struct) and then dt_struct.hour and dt_struct.min

I tried I do not know how to use this function

Can you say something in detail?

Petr Nosek
1292
Petr Nosek  
moslemS:

I tried I do not know how to use this function

Can you say something in detail?

void OnStart()
  {
   MqlDateTime dt_struct;
   datetime dtSer=TimeCurrent(dt_struct);
   printf("Server time: %d:%d:%d ; Just hours: %d ; Just minutes: %d",dt_struct.hour,dt_struct.min,dt_struct.sec,dt_struct.hour,dt_struct.min);
  }
This script print info about server time in terminal window (tab Strategy)
moslemS
43
moslemS  
Petr Nosek:
This script print info about server time in terminal window (tab Strategy)

how to use this code in Comment() in expert ?


   MqlDateTime dt_struct;
   datetime dtSer=TimeCurrent(dt_struct);

void OnTick()
  {


int mins = dt_struct.min ;
Comment(mins) ;

  }

Because this code is not true

Alain Verleyen
36170
Alain Verleyen  

Forum on trading, automated trading systems and testing trading strategies

Script/EA to open buy/sell position few pips away from current

Alain Verleyen, 2016.03.30 10:46

Welcome,

  • Usually people who can't code don't receive free help on this forum, though it could happen if you are lucky, be patient.
  • If you show your attempts and describe well your problem, you will most probably receive an answer from the community.
  • If you don't want to learn to code, nothing bad, you can either look at the Codebase if something free already exists, or in the Market for paid products (sometimes free also).
  • Finally, you also have the option to hire a programmer in the Freelance section.

Good luck.


moslemS
43
moslemS  

i have no experience in time functions in mql5

I want to display the minutes and hours of market in my Expret by Comment()

For example, I use this code to display seconds


int Seconds( void )
{
  return((int)TimeCurrent() % 60) ;
}


void OnTick()

{

int sec = Seconds() ;

Comment(sec) ;

}


but I do not know how to display the minute and the hours

Alain Verleyen
36170
Alain Verleyen  
moslemS
43
moslemS  
Alain Verleyen:


i have no experience in time functions in mql5

I want to display the minutes and hours of market in my Expret by Comment()

For example, I use this code to display seconds

int Seconds( void )
{
  return((int)TimeCurrent() % 60) ;
}


void OnTick()

{

int sec = Seconds() ;

Comment(sec) ;

}

but I do not know how to display the minute and the hours

Alain Verleyen
36170
Alain Verleyen  
moslemS:

i have no experience in time functions in mql5

I want to display the minutes and hours of market in my Expret by Comment()

For example, I use this code to display seconds

but I do not know how to display the minute and the hours

I asked you to edit your first post, not to create a new one, but ok not a problem you know it for an other time.

Anyway, Petr already answered you how to get minutes and hours, you just have to use this code and add minutes and hours to your Comment() statement.

moslemS
43
moslemS  
Alain Verleyen:

I asked you to edit your first post, not to create a new one, but ok not a problem you know it for an other time.

Anyway, Petr already answered you how to get minutes and hours, you just have to use this code and add minutes and hours to your Comment() statement.

Sorry
but this code is not true
   MqlDateTime dt_struct;
   datetime dtSer=TimeCurrent(dt_struct);

void OnTick()
  {

int min = dt_struct.min ;
Comment(min) ;

  }
12
To add comments, please log in or register