Vertical Line, Get Datetime?

 

Hello to Everyone!,

I would like to know if is possible to get the datetime from a Vertical Line Object?


img attached!


Thanks in advanced!

Regards!

Files:
example.png  5 kb
 
fdesu:

Hello to Everyone!,

I would like to know if is possible to get the datetime from a Vertical Line Object?


img attached!


Thanks in advanced!

Regards!

Script:

//+------------------------------------------------------------------+
//|                                               OBJ_VLINE Info.mq5 |
//|                              Copyright © 2021, Vladimir Karputov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2021, Vladimir Karputov"
#property version   "1.000"
#property script_show_inputs
//--- input parameters
input string   InpName  = "VLine";  // VLine Name
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   long chart_id=ChartID();
   if(ObjectFind(chart_id,InpName)<0)
     {
      Print("ERROR: object ('",InpName,"') not found");
     }
   else
     {
      long obj_type=ObjectGetInteger(chart_id,InpName,OBJPROP_TYPE);
      if(obj_type!=OBJ_VLINE)
        {
         Print("ERROR: object ('",InpName,"') is not a 'OBJ_VLINE' - object is ",EnumToString((ENUM_OBJECT)obj_type));
        }
      else
        {
         datetime obj_time=(datetime)ObjectGetInteger(chart_id,InpName,OBJPROP_TIME);
         Print("OBJ_VLINE '",InpName,"' time: ",TimeToString(obj_time,TIME_DATE|TIME_SECONDS));
        }
     }
  }
//+------------------------------------------------------------------+
Files:
 
Vladimir Karputov:

Script:

Thanks u Very much!

 
fdesu #:

¡Muchas gracias!

Hello Vladimir !


would you be so kind but in mql4

Thanks u Very much!

 
Manuel de los Heros Soler #: Hello Vladimir! would you be so kind but in mql4. Thanks u Very much!

Forget it. Vladimir will no longer offer any help or support for the MT4. He is dedicated to MT5 and MQL5 only!

However, the above code should function for MQL4, and if not, it will only need minor modifications. So try it for yourself. Just change the file extension to ".mql4" and add the "#property strict".

 

Perhaps you should read the manual. MQL4 ReferenceObject FunctionsObjectGetIntegerENUM_OBJECT_PROPERTY_INTEGER → OBJPROP_TIME

 
fernando carrero #:

Olvídalo. Vladimir ya no ofrecerá ayuda ni soporte para MT4. ¡Él está dedicado únicamente a MT5 y MQL5!

Sin embargo, el código anterior debería funcionar para MQL4 y, de no ser así, solo necesitará modificaciones menores. Así que pruébalo por ti mismo. Simplemente cambie la extensión del archivo a ".mql4" y agregue "#propiedad estricta".

OKAY! Thank you very much.
 
Manuel de los Heros Soler #:
OKAY! Thank you very much.
datetime obj_time=(datetime)ObjectGetInteger(chart_id,InpName,OBJPROP_TIME);
// inpName would be that of the vertical line