A better version of this function, but something can be tweaked (in general, I would implement all this as an object, or several objects).
Although, you can put the function in a library and use it however you want.
bool Create_BMP_Label(long chart_id, // id графикаstring bmp_nm, // имя объектаstring bmp_path, // путь к обектуlong anchor, // точка привязкиlong corner, // угол привязкиint x_dist, // координата по шкале Xint y_dist) // координата по шкале Y
{
//----------------------------------------------------------------------------////Work variablesbool Result = true; //Returned importance//----------------------------------------------------------------------------//ResetLastError();
Result = ObjectCreate(chart_id,bmp_nm,OBJ_BITMAP_LABEL,0,0,0); // создание объектаif(Result)
{
ObjectSetString(chart_id,bmp_nm,OBJPROP_BMPFILE,0,bmp_path); // BMP файлObjectSetInteger(chart_id,bmp_nm,OBJPROP_ANCHOR,anchor); // установка точки привязкиObjectSetInteger(chart_id,bmp_nm,OBJPROP_CORNER,corner); // установка угола привязкиObjectSetInteger(chart_id,bmp_nm,OBJPROP_XDISTANCE,x_dist); // установка координаты XObjectSetInteger(chart_id,bmp_nm,OBJPROP_YDISTANCE,y_dist); // установка координаты YObjectSetInteger(chart_id,bmp_nm,OBJPROP_SELECTABLE,false); // нельзя выделить объект, если FALSEObjectSetString(chart_id,bmp_nm,OBJPROP_TOOLTIP,"\n"); // нет всплывающей подсказки, если "\n"
}
//The execution errors checkingif(GetLastError()!=0)
{
Result = false;
}
//----------------------------------------------------------------------------//return(Result);
//----------------------------------------------------------------------------//
}
A better version of this function, but something can be tweaked (in general, I would implement all this as an object, or several objects).
Although, you can put the function in a library and use it however you want.
It's nice.)) And in the form of an object, what's the advantage, if you take this function as an example? So far, I have implemented everything in the form of functions. Maybe I'm going in the wrong direction and will have to redo everything later?
tol64: (That's nice.)). What is the advantage of using this function as an object? For now I have implemented everything in the form of functions. Maybe I follow the wrong way and will have to redo everything later?
Well, why all of them. A function could be made more universal and packed into, say, a library.
Classes have advantages too, but these are tricks related to OOP (the main task will be to use the code in various projects without thinking about the implementation).
Example
As I see from the screenshot, you have something like an information panel (maybe some other functionality), so you can consider this panel as a number of unrelated objects (graphics, text, etc.), or you can view them as objects connected by one class. Thus, if you change one "input" parameter "Corner", this change will affect all that relates to the panel.
It is the same with the binding to the chart. By specifying a chart to the class, we indicate this chart to all objects controlled by the class as well.
Well, why all of them. A function could be made more universal and packed into, say, a library.
Classes have advantages too, but these are tricks of OOP (the main task will be to use the code in various projects without thinking about the implementation).
Example
As I see from the screenshot, you have something like an information panel (maybe some other functionality), so you can consider this panel as a number of unrelated objects (graphics, text, etc.), or you can view them as objects connected by one class. So if you change one "input" parameter "Corner", this change will affect all that relates to the panel.
I have the same problem with the binding to the chart. Once we indicate a chart to the class, we indicate this chart and all objects that this class controls.
You have a very remarkable ability. Explain everything very clearly in a couple of lines. Thank you. ))
After I get acquainted with all the functions I need and practice using them, I'll start to study the structures, classes and OOP. It's a pity that nature forces me to go to bed sometimes. I have to crawl away from the computer. ))
The task: delete all objects of OBJ_LABEL type from a chart. But some of them are skipped and remain. An error is written in the log:
Please advise how to do it correctly.
It seems to me that the loop should be descending rather than ascending, although I haven't gone into details (but since MQL4 the deletion of orders has been done in a descending loop).
The trick is that if you start deleting from large indexes then the original list won't change, except for deleting selected item (from the tail of the list)...
It seems to me that the cycle should be descending rather than ascending, although I haven't gone into details (since MQL4, orders are deleted in a descending cycle).
The trick is that if we start deleting from a large index then the original list won't change, except for deleting a selected item (from the tail of the list)...
I have tried to start the cycle from the end:
for(i=amount_obj-1; i>=amount_obj; i--)
Now there are no errors in log, but not a single object is deleted).
In quadruplet, I use this approach: all objects are groups, the name part is common in the group.
Deleting
// удаление по маске всех объектов индюкаfor (int i = ObjectsTotal() - 1; i >= 0; i--)
{
string name = ObjectName(i);
if (StringFind(name, "sig_nal") == 0)
{
ObjectDelete(name);
}
}
for different groups
// удаление по маске всех объектов индюкаfor (int i = ObjectsTotal() - 1; i >= 0; i--)
{
string name = ObjectName(i);
if (StringFind(name, "signal") == 0)
{
ObjectDelete(name);
}
elseif (StringFind(name, "Asignal") == 0)
{
ObjectDelete(name);
}
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I pass these object properties explicitly (ANCHOR_RIGHT_UPPER, CORNER_RIGHT_UPPER):
I think I've got it. Did you show a sample function, not a working piece of code?
That's it, I'm taking the weekend off. Sorry for the interruption :)
A better version of this function, but something can be tweaked (in general, I would implement all this as an object, or several objects).
Although, you can put the function in a library and use it however you want.
A better version of this function, but something can be tweaked (in general, I would implement all this as an object, or several objects).
Although, you can put the function in a library and use it however you want.
(That's nice.)). What is the advantage of using this function as an object? For now I have implemented everything in the form of functions. Maybe I follow the wrong way and will have to redo everything later?
Well, why all of them. A function could be made more universal and packed into, say, a library.
Classes have advantages too, but these are tricks related to OOP (the main task will be to use the code in various projects without thinking about the implementation).
Example
As I see from the screenshot, you have something like an information panel (maybe some other functionality), so you can consider this panel as a number of unrelated objects (graphics, text, etc.), or you can view them as objects connected by one class. Thus, if you change one "input" parameter "Corner", this change will affect all that relates to the panel.
It is the same with the binding to the chart. By specifying a chart to the class, we indicate this chart to all objects controlled by the class as well.
Well, why all of them. A function could be made more universal and packed into, say, a library.
Classes have advantages too, but these are tricks of OOP (the main task will be to use the code in various projects without thinking about the implementation).
Example
As I see from the screenshot, you have something like an information panel (maybe some other functionality), so you can consider this panel as a number of unrelated objects (graphics, text, etc.), or you can view them as objects connected by one class. So if you change one "input" parameter "Corner", this change will affect all that relates to the panel.
I have the same problem with the binding to the chart. Once we indicate a chart to the class, we indicate this chart and all objects that this class controls.
You have a very remarkable ability. Explain everything very clearly in a couple of lines. Thank you. ))
After I get acquainted with all the functions I need and practice using them, I'll start to study the structures, classes and OOP. It's a pity that nature forces me to go to bed sometimes. I have to crawl away from the computer. ))
I have written this script:
Task: remove all objects of type OBJ_LABEL from the chart. But some are skipped and remain. An error is written in the logbook:
Please tell me how to do it correctly.
I have written such a script:
The task: delete all objects of OBJ_LABEL type from a chart. But some of them are skipped and remain. An error is written in the log:
Please advise how to do it correctly.
It seems to me that the loop should be descending rather than ascending, although I haven't gone into details (but since MQL4 the deletion of orders has been done in a descending loop).
The trick is that if you start deleting from large indexes then the original list won't change, except for deleting selected item (from the tail of the list)...
It seems to me that the cycle should be descending rather than ascending, although I haven't gone into details (since MQL4, orders are deleted in a descending cycle).
The trick is that if we start deleting from a large index then the original list won't change, except for deleting a selected item (from the tail of the list)...
I have tried to start the cycle from the end:
Now there are no errors in log, but not a single object is deleted).
Tried to start the cycle from the end:
Now there are no errors in the logbook, but no objects are deleted either.)
In quadruplet, I use this approach: all objects are groups, the name part is common in the group.
Deleting
for different groups
and here function IgorM
***
( just in case ) Sorting by ObjectName(not sure if it is relevant for 5)