Download MetaTrader 5

Object Problem

To add comments, please log in or register
Edgar71
26
Edgar71  

Hi there,


I´m just getting insane of it...

ObjectCreate(NULL,"Put",OBJ_TEXT,0,iTime(NULL,0,1),iClose(NULL,0,1),0,0,0,0);
ObjectSetText("Put","US",0,NULL,clrNONE);
  
  
   string test1 = ObjectGet("Put",OBJPROP_TIME1);
   Alert(test1);
   string test2 = ObjectGet("Put",OBJPROP_PRICE1);
   Alert(test2);
   string test3 = ObjectGet("Put",OBJPROP_TEXT);
   Alert(test3);

Why do I get an output of "0" at test3? What do I have not on my mind?

Thanks in advance!

honest_knave
Moderator
2322
honest_knave  

Give it a go with the new style calls:

ObjectCreate(0,"Put",OBJ_TEXT,0,Time[1],Close[1]);
ObjectSetString(0,"Put",OBJPROP_TEXT,"US");
Alert(ObjectGetInteger(0,"Put",OBJPROP_TIME));
Alert(ObjectGetDouble (0,"Put",OBJPROP_PRICE));
Alert(ObjectGetString (0,"Put",OBJPROP_TEXT));
(I also changed your iTime() and iClose() calls because it is quicker to use Time[] and Close[] when dealing with the current symbol / timeframe)
Edgar71
26
Edgar71  
honest_knave:

Give it a go with the new style calls:

(I also changed your iTime() and iClose() calls because it is quicker to use Time[] and Close[] when dealing with the current symbol / timeframe)

I could swear, I tested ObjectGetString before and it didn´t work. Maybe I´ve done something other wrong there.

Thanks, honest_knave, now I can sleep well again... ;-)

To add comments, please log in or register