Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1326

 
DanilaMactep:

More than once I've seen such variables changed without any problemsin video tutorials.

I'd like to see it too, can I get a link?

DanilaMactep:

Please give real clear and sensible advice

Post#13247

 

Can you tell me how to find an object by a name that is not full?

The indicator creates objects and gives them a name

HlineCreate(0,"Min"+rand(),...);

Find the object and delete it if its price is lower than the current price

 
MakarFX:

Can you tell me how to find an object by a name that is not full?

The indicator creates objects and gives them a name

I need to find an object and delete it if its price is lower than the current one

Is it?

StringFind

Search for substring in string.

intStringFind(
stringstring_value,//string string we are looking for
stringmatch_substring,//what we are looking for
intstart_pos=0// which position to start search
);

Parameters

string_value

[in] String to search in.

match_substring

[in] Match_substring to be searched.

start_pos=0

[in] Position in the string where the search should be started.

Returned value

Returns position number in the string where the substring to be searched starts, or -1 if no substring is found.

 
Vitaly Muzichenko:

This?

Probably not...

or rather, I don't know how to link it to the object search.

I'm trying.

 for(int i=0;i<ObjectsTotal();i++)
     ObjectDelete(0,"Min"+IntegerToString(i));

but it's not working.

 
MakarFX:

Probably not...

or rather, I don't know how to link it to an object search.

I'm still trying.

but it just doesn't work(

for(int i=0;i<ObjectsTotal();i++) {
 if(StringFind(получим имя объекта,"Min")>-1) { // ObjectName
   ObjectDelete(0,"полученное имя");

stringObjectName(
intobject_index// number in object list
);

 

I suggest this:

int obj_total=ObjectsTotal(); 
 
   for(i=obj_total-1;i>=0;i--) 
     { 
      string name=ObjectName(i); 
      if(StringFind(name,"Min",0)!=-1)
        {
        ObjectDelete(name);
        } 
     } 
 
Vitaly Muzichenko:


Alekseu Fedotov:

Thanks, I'll try both now)

 

Made it like this.

 for(int a = 0; a<ObjectsTotal() ;a++)
  {
   if(ObjectGet(ObjectName(a),OBJPROP_PRICE1)>iHigh(Symbol(),PERIOD_D1,1))
   if(ObjectDelete(ObjectName(a)))Print("Delete");
  }

Works flawlessly!

Thank you all)

 

Hello. Question about the cost of the item. I am doing this:

MarketInfo("EURCAD",MODE_TICKVALUE) 
MarketInfo("USDCAD",MODE_TICKVALUE)

I get the same values on these two pairs. Is this how it works? Or is it a glitch?

 
MakarFX:

Made it like this.

Works flawlessly!

Thank you all)

The cycle must be reversed. Otherwise there will be questions about why it didn't work perfectly.