Questions from a "dummy" - page 263

 
Contender:

Try using StringConcatenate() to "glue" the strings together

Replaced by

StringConcatenate(nTL,"nTL_",IntegerToString(MathRand()));
did not help.
 
Silent:
I'll be racking my brains for another week. Can you give me some more details? (can be rough :))

Is there another option for a couple of hundred objects with unique names?

(A group of objects must have the same part of the string in the name, to remove the group.)

Counter
 
TheXpert:

Well, logically, if the function sets last error at all, then on successful completion of the function there should be a zero error value or the value described in the documentation. There is no other way.

I.e. if the call was successful and the error is non-zero, this case should be described in the documentation.

That's what I thought too, until I was convinced otherwise. Wrote a request to the SD, I got an answer like I did above :)
 
220Volt:

Are you worried because Get Last Errors prints something other than zero? If so, you should only ask for an error if the function reports a failure. And you shouldn't ask for an error at the end of the plot, you might get a rubbish value. This is how it is in MT4, maybe it is different here.

Pseudocode:

The error should be cleared by ResetLastError(), but if there is an assignment going on, it is equivalent.
 
Silent:

My recommendation: re-do the Get LastError according to the principle I described above. Only then will you get the error that occurs, maybe you get something else.

 
220Volt:
I thought so too, until I was convinced otherwise. Wrote a request to the SD and I got the same answer as I did above :)
Brayed.
 

Reset is reset before the call is made.

This is what causes the error

void  CreateTL(string name,datetime time1,double price1,datetime time2,double price2,bool ray_left,bool ray_right,color color_TL)
  {
//------------ nTL,nTLh,nTLl,nTLe
   nTL="nTL_"+IntegerToString(MathRand());
   nTLh="nTLh_"+IntegerToString(MathRand());
   nTLl="nTLl_"+IntegerToString(MathRand());
   nTLe="nTLe_"+IntegerToString(MathRand());
//------------
   ObjectCreate(0,name,OBJ_TREND,0,time1,price1,time2,price2);
  };

There is no error in this variant

void  CreateTL(string name,datetime time1,double price1,datetime time2,double price2,bool ray_left,bool ray_right,color color_TL)
  {
//------------ nTL,nTLh,nTLl,nTLe
   //nTL="nTL_"+IntegerToString(MathRand());
   //nTLh="nTLh_"+IntegerToString(MathRand());
   //nTLl="nTLl_"+IntegerToString(MathRand());
   //nTLe="nTLe_"+IntegerToString(MathRand());
//------------
   ObjectCreate(0,nTL="nTL_"+IntegerToString(MathRand());,OBJ_TREND,0,time1,price1,time2,price2);
  };
 
zfs:
Counter
What difference does it make? Same numbers in a string.
 
Silent:
What difference does it make? It's the same numbers on the line.
There is no guarantee that the numbers won't match. Potential for error.
 
zfs:
There is no guarantee that the numbers will not match. Potential error.

First of all, there is no chance (Urain's code has never failed)

x=0;  MathSrand(x);
   for(i=0;i<MathRand();i++)MathRand();
   MathSrand((int)TimeLocal()*MathRand());

Secondly, I have an error (and no object created) exactly on the first call.

Документация по MQL5: Основы языка / Операторы / Оператор создания объекта new
Документация по MQL5: Основы языка / Операторы / Оператор создания объекта new
  • www.mql5.com
Основы языка / Операторы / Оператор создания объекта new - Документация по MQL5