OBJPROP_CREATETIME different from Market Watch time

 

Hello everyone,

I have an issue with the subject.

I draw 1 object only on the chart.

I tried to print the create time of the last object I made on the chart, but I get different time of 3 hours.

Market Watch show time 16:05, but I get 13:05 on the print result.

int totobj = ObjectsTotal();
   for(int i=totobj-1; i>=0; i--)
     {
      string objname = ObjectName(i);
      Print("c time = ",TimeToStr(ObjectGetInteger(0,objname,OBJPROP_CREATETIME)));
     }

Anyone can explain why I get different result from the Market Watch?

Thank you for your help.

 
Donald Reeves Sihombing: Anyone can explain why I get different result from the Market Watch?

We can't see your broken code. With the information you've provided — we can only guess.

You created the object at 13:05, never deleted it. Then tried to create it again at 16:05 which failed.

If you had bothered to check your return codes, you would know why. Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
          What are Function return values ? How do I use them ? - MQL4 programming forum
          Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

 
William Roeder:

We can't see your broken code. With the information you've provided — we can only guess. You created the object at 13:05, never deleted it. Then tried to create it again at 16:05 which failed and you don't bother to check your return codes.

Actually, I create the object at 16:05, not 13:05

 

For now. I use GlobalVariable.

So, if the EA found any new object, it will check the GlobalVariable regarding that object name.

 int totobj = ObjectsTotal();
   for(int i=totobj-1; i>=0; i--)
     {
      string objname = ObjectName(i);
      string gvname = Symbol()+"_"+objname;
      if(GlobalVariableCheck(gvname)==false)
        {
         datetime settime = TimeCurrent();//this is acting as the create time
         double timedel = (double)settime;
         GlobalVariableSet(gvname,timedel);
        }
     }