Display time

 

I planning to do an indicator to display the current time on the chart as the font are really too small to see. Can anyone advise me what's the function to use for time? I read the code and found they use Datetime constant 'D' but i dont' understand this area. anyone can advice me on this.

Secondly any short cut to del all the trend line? For those arrow, we can right click and del all arrow, but this dont' apply to trend line. Thanks

 

The current time is held in seconds so you have to get the current time and figure out what the hours, minutes and seconds are using the "Date & Time" function calls like this:

int h=TimeHour(TimeCurrent());

int m=TimeMinute(TimeCurrent());

int s=TimeSeconds(TimeCurrent());


Then you can print h:m:s


I would set up a template of the chart without any trend lines then each time you want to start a fresh just dump the template on the chart.

 
georgecheng:

I planning to do an indicator to display the current time on the chart as the font are really too small to see. Can anyone advise me what's the function to use for time? I read the code and found they use Datetime constant 'D' but i dont' understand this area. anyone can advice me on this.

You need to convert datetime to a string:

string time = TimeToStr(TimeCurrent(),TIME_SECONDS);   // TIME_SECONDS outputs time in format ->  hh:mm:ss


See here -> https://docs.mql4.com/convert/TimeToStr

 
gordon wrote >>

You need to convert datetime to a string:


See here -> https://docs.mql4.com/convert/TimeToStr

Thanks,

On top of that, i like to know is it possible to have text shown in the chart in the same row using only one function as below with 2 identifiers. I looking to make market price and current time display in the same row using this function. Do I have to create 2 set of these function for each identifier or I can put them together. If possible to put them together, how should i do it? I tried using "" and + but failed. Thank

ObjectCreate(OBJ_NAME, OBJ_LABEL, 0, 0, 0);
ObjectSet(OBJ_NAME, OBJPROP_CORNER, 0);
ObjectSet(OBJ_NAME, OBJPROP_YDISTANCE, 20);
ObjectSet(OBJ_NAME, OBJPROP_XDISTANCE, 3);
ObjectSetText(OBJ_NAME, XX, 10, "FixedSys", LabelColor);

Reason: