Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1373

 
Trying.
 
Nikita Chernyshov #:

The buffer should not be caught by the colour, but by the value.

Look at what the buffer outputs when it changes colour.

I.e. let's say there are two buffers. Red and green.

Output these two buffers via Commen and trace what the buffer shows when it is 'active'. These are numerical values. These are the ones you interact with.

Don't give advice that is suitable for mql4 and not always suitable for mql5

 
Oleg Kolesov #:
Hello. How do I get the colour index in the Expert Advisor? (To get a signal when a colour changes).

As a rule, an indicator has a value buffer first, followed by a colour buffer.

   SetIndexBuffer(0, buffMACD, INDICATOR_DATA);           // Буфер данных
   SetIndexBuffer(1, colorBuff, INDICATOR_COLOR_INDEX);   // Буфер цвета
   SetIndexBuffer(2, buffSignal, INDICATOR_DATA);         // Буфер данных
   SetIndexBuffer(3, colorSignal, INDICATOR_COLOR_INDEX); // Буфер цвета

Then you copy the values of the 1st or 3rd buffer after receiving the indicator handle. There can be only integer values from zero, 0 and above, depending on the number of colours defined in the indicator. All you need to know when programming the EA.

 

Can you tell me how to create a graphical object in MQL5 to avoid error 4202?

I used this code in MQL4:

   string Obj_Rectangle="Object"; 

   if(ObjectFind(0,Obj_Rectangle)==-1)                               
     {
      ObjectCreate(0,Obj_Rectangle,OBJ_RECTANGLE_LABEL,0,0,0);        
      ObjectSetInteger(0,Obj_Rectangle,OBJPROP_CORNER,0);
      ObjectSetInteger(0,Obj_Rectangle,OBJPROP_XDISTANCE,100);
      ObjectSetInteger(0,Obj_Rectangle,OBJPROP_YDISTANCE,100);
      ObjectSetInteger(0,Obj_Rectangle,OBJPROP_XSIZE,200);
      ObjectSetInteger(0,Obj_Rectangle,OBJPROP_YSIZE,150);
      ObjectSetInteger(0,Obj_Rectangle,OBJPROP_BGCOLOR,clrBlue);
     }
     
   Alert(_LastError);

But in MQL5 ObjectFind() returns error 4202

 
leon_17 #:

Can you tell me how to create a graphical object in MQL5 to avoid error 4202?

I used this code in MQL4:

But in MQL5, ObjectFind() returns error 4202

If no object is found, it is an object search error...

ERR_OBJECT_NOT_FOUND

4202

Graphical object not found


Don't alerts it...

 
Alexei, thank you for wanting to help. You too have the principle: to the hungry a rod, not a fish.
 
Alexey Viktorov #:

If no object is found, this is the object search error...

ERR_OBJECT_NOT_FOUND

4202

Graphic object not found


You don't have to alert it...

Well, I was once taught that _LastError shouldn't return any errors at all. And it even seemed to be a requirement of the marketplace. Is it not so strict anymore?

And also, as far as I understand, this error could overwrite, some other more important error in the code, how to deal with that?

 
leon_17 #:

Well, I was once taught that _LastError should not return any errors at all. And it even seemed to be a requirement of the marketplace. Is it not so strict anymore?

And also, as far as I understand, this error could overwrite, some other more important error in the code, how to deal with it?

The _LastError variable stores the value of last error that occurred during execution of mql5-program.

Somebody taught you badly. The _LastError variable will store the obtained value until the next, next error occurs.

It is a requirement of the marketplace that no execution errors are received from the broker server\dc. Read documentation...

Документация по MQL5: Предопределенные переменные / _LastError
Документация по MQL5: Предопределенные переменные / _LastError
  • www.mql5.com
_LastError - Предопределенные переменные - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Oleg Kolesov #:
Alexei, thank you for wanting to help. You, too, have the principle: to the hungry a rod, not a fish.
Not just a fishing rod, but an explanation of where to read about solving the problem. If a person wants to understand the problem, I am prepared to spend time until they understand my words. But if they ask you to do it and I use this template to figure it out, then the person won't figure it out. He needs someone to do it, and then the grass grows...
 
I agree.
Reason: