Download MetaTrader 5
To add comments, please log in or register
Code Base will help you in mastering your theoretical skills. Come and learn!
Pavel Soukup
559
Pavel Soukup 2015.05.28 12:12 

In old version MT4 (Build 600-) was possible create objects in Tester - visual mode.

But for new build 600+ my code not function, wrote "Error: can't create object name:tester code #4202"

If I use the same code as script and add to chart (no chart tester), object create ok.

   long current_chart_id=ChartID();
   string name="tester";
//--- creating label object (it does not have time/price coordinates)
   if(!ObjectCreate(current_chart_id,name,OBJ_TEXT,0,0,0))
     {
      Print("Error: can't create object name:", name," code #",GetLastError());
     }

   ObjectSetDouble(current_chart_id,name,OBJPROP_PRICE,Low[0]-100*Point);
   ObjectSetInteger(current_chart_id,name,OBJPROP_TIME,Time[0]);
   ObjectSetInteger(current_chart_id,name,OBJPROP_COLOR,clrWhite);
   //--- set text property
   ObjectSetString(current_chart_id,name,OBJPROP_FONT, "Wingdings" );
   ObjectSetString(current_chart_id,name,OBJPROP_TEXT, CharToStr(140) );

 When is error?

Keith Watford
Moderator
7947
Keith Watford 2015.05.28 12:59  

Are you sure the error code is 4202?

4202

ERR_OBJECT_DOES_NOT_EXIST

Object does not exist

 

 That doesn't make sense, you would would expect that error when modifying object properties.

Pavel Soukup
559
Pavel Soukup 2015.05.28 13:06  
GumRai:

Are you sure the error code is 4202?

4202

ERR_OBJECT_DOES_NOT_EXIST

Object does not exist

 

 That doesn't make sense, you would would expect that error when modifying object properties.

:-) I know code 4202 GetLastError(), I don´t know why the same code in script is valid, create object. In tester mode return error.... ???
Keith Watford
Moderator
7947
Keith Watford 2015.05.28 13:56  

I tried your code and got the same result as you.

It seems that the problem stems from ChartID()

This code

void OnTick()
  {

   //long current_chart_id=ChartID();
   string name="tester";
   if(ObjectFind(0,name)<0)
     {
      if(!ObjectCreate(0,name,OBJ_TEXT,0,0,0))
        {
         Print("Error: can't create object name:",name," code #",GetLastError());
        }
     }
   ObjectSetDouble(0,name,OBJPROP_PRICE,Low[0]-100*Point);
   ObjectSetInteger(0,name,OBJPROP_TIME,Time[0]);
   ObjectSetInteger(0,name,OBJPROP_COLOR,clrWhite);
//--- set text property
   ObjectSetString(0,name,OBJPROP_FONT,"Wingdings");
   ObjectSetString(0,name,OBJPROP_TEXT,CharToStr(140));
//---

  }

 using 0 for the current chart works perfectly

Alain Verleyen
Moderator
28626
Alain Verleyen 2015.05.28 21:27  
GumRai:

I tried your code and got the same result as you.

It seems that the problem stems from ChartID()

This code

 using 0 for the current chart works perfectly

Yes with the STretagy Tester, it must always be 0.
Pavel Soukup
559
Pavel Soukup 2015.06.03 08:19  
angevoyageur:
Yes with the STretagy Tester, it must always be 0.

You have true!  

Support graphical objects in only Visual Mode! 

if (IsVisualMode() ) current_chart_id=0;

if (IsVisualMode() ) current_chart_id=0;
.... <others code>
/
To add comments, please log in or register