VLine ObjectGet() not properly getting data (Possible miss understanding of the help file)

 

Add Vline to chart for testing..


void OnStart()
  {
//---
// Object On chart name = sName;
string sTemp = "Vertical Line 55321";
string sName;
string sAfterIteration; 
datetime time1,time2,time3,time4,time5;
datetime time6,time7,time8,time9,time0;

int iType = -1;
string sType;
ENUM_OBJECT iNum;

int obj_total = ObjectsTotal();

for(int i=0;i<obj_total;i++){ 
      sName = ObjectName(i);
      iType = ObjectType(sName);
      iNum = (ENUM_OBJECT) iType;
      sType = EnumToString(iNum); 
      
      if(sType == "OBJ_VLINE"){  
         sAfterIteration = sName;
         Print(sAfterIteration);     
         Print("Object Type Enumeration",iNum);
         Print("Object String from Enumeration",sType);
             
         } //End IF

      }//End FOR     

Print("On to testing VLine datetime");


//+------------------------------------------------------------------+
//|ObjectGet                                                                  |
//+------------------------------------------------------------------+
time1 = (datetime)ObjectGet(sAfterIteration,OBJPROP_TIME1);
Print ("ObjectGet OBJPROP_TIME1 ",time1);

time2 = (datetime)ObjectGet(sAfterIteration,OBJPROP_TIME2);  
Print ("ObjectGet OBJPROP_TIME2 ",time2);

time3 = (datetime)ObjectGet(sAfterIteration,OBJPROP_TIME3);  
Print ("ObjectGet OBJPROP_TIME3 ",time3);

time4 = (datetime)ObjectGet(sAfterIteration,OBJPROP_TIME);
Print ("ObjectGet OBJPROP_TIME ",time4);

time5 = (datetime)ObjectGet(sAfterIteration,OBJPROP_CREATETIME);
Print ("ObjectGet OBJPROP_CREATETIME ",time5);


//+------------------------------------------------------------------+
//|ObjectGetInteger                                                                  |
//+------------------------------------------------------------------+
time6 = (datetime)ObjectGetInteger(0,sAfterIteration,OBJPROP_TIME1);
Print ("ObjectGetInteger OBJPROP_TIME1 ",time6); 

time7 = (datetime)ObjectGetInteger(0,sAfterIteration,OBJPROP_TIME2); //enum 
Print ("ObjectGetInteger OBJPROP_TIME2 ",time7);

time8 = (datetime)ObjectGetInteger(0,sAfterIteration,OBJPROP_TIME3);  //possible loss of data due to type converstion
Print ("ObjectGetInteger OBJPROP_TIME3 ",time8);

time9 = (datetime)ObjectGetInteger(0,sAfterIteration,OBJPROP_TIME);
Print ("ObjectGetInteger OBJPROP_TIME ",time9);

time0 = (datetime)ObjectGetInteger(0,sAfterIteration,OBJPROP_CREATETIME);
Print ("ObjectGetInteger OBJPROP_CREATETIME ",time0);  
  }
//+------------------------------------------------------------------+
/*  Enumerations for datetime functions to see what available for use
OBJPROP_TIME1=0
OBJPROP_TIME2=2
OBJPROP_TIME3=4
OBJPROP_COLOR=6
OBJPROP_STYLE=7
OBJPROP_WIDTH=8
OBJPROP_BACK=9
OBJPROP_RAY=10
OBJPROP_ELLIPSE=11
OBJPROP_ARROWCODE=14
OBJPROP_TIMEFRAMES=15
OBJPROP_SELECTED=17
OBJPROP_TYPE=18
OBJPROP_TIME=19
OBJPROP_FONTSIZE=100
OBJPROP_CORNER=101
OBJPROP_XDISTANCE=102
OBJPROP_YDISTANCE=103
OBJPROP_LEVELS=200
OBJPROP_LEVELCOLOR=201
OBJPROP_LEVELSTYLE=202
OBJPROP_LEVELWIDTH=203
OBJPROP_ZORDER=207
OBJPROP_HIDDEN=208
OBJPROP_CREATETIME=998
OBJPROP_SELECTABLE=1000
OBJPROP_RAY_LEFT=1003
OBJPROP_RAY_RIGHT=1004
OBJPROP_ANCHOR=1011
OBJPROP_DIRECTION=1014
OBJPROP_STATE=1018
OBJPROP_XSIZE=1019
OBJPROP_YSIZE=1020
OBJPROP_PERIOD=1022
OBJPROP_DATE_SCALE=1023
OBJPROP_PRICE_SCALE=1024
OBJPROP_BGCOLOR=1025
OBJPROP_CHART_SCALE=1027
OBJPROP_READONLY=1028
OBJPROP_BORDER_TYPE=1029
OBJPROP_CHART_ID=1030
OBJPROP_FILL=1031
OBJPROP_XOFFSET=1033
OBJPROP_YOFFSET=1034
OBJPROP_BORDER_COLOR=1035
OBJPROP_ALIGN=1036

limited enum of 2000
*/
 
datetime time = ObjectGetInteger(0,name,OBJPROP_TIME);
 
Marco vd Heijden:
datetime time = (datetime)ObjectGetInteger(0,name,OBJPROP_TIME);

I think you are playing with me now.. :)

I will not use ObjectGet().. :)

I was reading over the documentation about 2 hour after I posted and I see from the coding samples that ObjectGet() and OBJ_TIME is not shown..
OBJPROP_TIME1, OBJPROP_TIME2, OBJPROP_TIME3 is used..

Example would be time1 or time2..
When "time" is referenced in the code OBJPROP_TIME as a datetime variable it is used but only with ObjectGetInteger().. NOT ObjectGet();

I looked at the help file but did not look close enough.. sorry for wasting your time..

https://www.mql5.com/en/forum/155585
implicit enum conversion - enum to int
implicit enum conversion - enum to int
  • 2015.05.14
  • www.mql5.com
Hi! I want to explicitly convert 'enum' type into 'int' type...
 

A Vline object only has one time parameter but there can be cases where your object has multiple time and price parameters.

In that case you also have to specify which object point you are referring to.

 
Marco vd Heijden:

A Vline object only has one time parameter but there can be cases where your object has multiple time and price parameters.

In that case you also have to specify which object point you are referring to.

Thank you. I appreciate your help.
Reason: