The ObjectFind() function returns the number of the main window. And this number is 0. On the other hand, 0 == false, so it follows that if the function returns 0, it still returns false. Of course, I would not use this because if the function returns -1, i.e. an error, we may consider the location of the object not in the main window. On top of that, you never know what fixes will be made...
So don't argue and don't study how to do it...
The ObjectFind() function does not return the number of the main window. It will return the number of window where the object was found (0, 1, 2...) or -1 if the object doesn't exist.
I wonder if "-1" is false or true.
The booltype is used to store the boolean values true or false, with a numeric representation of 1 or 0 respectively .
The ObjectFind() function does not return the main window number. It is the number of window where the object is found (0,1,2...) or -1 if there is no object.
I was talking about specific case where object is located in main window. Don't argue and don't learn how to do it...
The ObjectFind() function returns the number of the main window. And this number is 0. On the other hand, 0 == false, so it follows that if the function returns 0, it still returns false. Of course, I would not use this because if the function returns -1, i.e. an error, we may consider the location of the object not in the main window. On top of that, you never know what fixes will be made...
So don't argue and don't learn how to do it...
I realize that you should not do so, but I had to for the sake of aesthetics (== 0 in every condition looks ugly). And I only need the object in the main window.
I know I shouldn't do this, but I had to for the sake of aesthetics (== 0 in every condition looks ugly). And I only need the object in the main window.
Problem: Yellow and grey lines ("Stop Sell" and "not allowed") are constantly created and flickering when the button is pressed on the chart. And ObjectCreate() constantly returns true instead of false, i.e. it creates as if in another window and that could explain the flickering... But the window is only the main one and there are no anomalies with the green line ("Buy Stop") as well as with the red one ("Stop Loss").
voidOnChartEvent(constint id, constlong &lparam, constdouble &dparam, conststring &sparam)
{
datetimestatic dt = 0;
doublestatic price = 0;
intstatic window = 0;
stringstatic line_name;
if(id==CHARTEVENT_OBJECT_CLICK){
...
//Нажатие на SO в зависимоти от расположения панели создаёт линиюif(sparam=="Button Stop Order"){
if(panel_position == 1 || panel_position == 2){
line_name = "Buy Stop";
CreateLine(line_name, clrGreen);
}
if(panel_position == 3 || panel_position == 4){
line_name = "Sell Stop";
CreateLine(line_name, clrYellow);
}
}
//Нажатие на линию удаляет её и создаёт краснуюif(sparam=="Buy Stop" || sparam=="Sell Stop"){
ObjectDelete(line_name);
line_name = "Stop Loss";
CreateLine(line_name, clrRed);
}
//Нажатие на красной линии удаляет её и отжимает кнопкуif(sparam=="Stop Loss"){
ObjectDelete(line_name);
button_name = "Button Stop Order";
ms=GetMicrosecondCount();
}
}
//Если кнопка SO нажата, то линия будет следовать за курсоромif(ObjectGetInteger(0,"Button Stop Order",OBJPROP_STATE)){
int x = (int)lparam;
int y = (int)dparam;
//Переведём координаты X, Y в дату и времяif(ChartXYToTimePrice(0,x,y,window,dt,price)){
//Линия меняет цвет с зелёного на желтыйif(price < Bid){
if(ObjectFind("Buy Stop") == window || ObjectFind("not allowed") == window){
ObjectDelete(line_name);
line_name = "Sell Stop";
CreateLine(line_name, clrYellow);
}
}
//Линия меняет цвет с желтого на зелёныйif(price > Ask){
if(ObjectFind("Sell Stop") == window || ObjectFind("not allowed") == window){
ObjectDelete(line_name);
line_name = "Buy Stop";
CreateLine(line_name, clrGreen);
}
}
//Линия меняет цвет на серый если в зоне спредаif(price > Bid && price < Ask){
if(ObjectFind("Buy Stop") == window || ObjectFind("Sell Stop") == window){
ObjectDelete(line_name);
line_name = "not allowed";
CreateLine(line_name, clrGray);
}
}
//Прикрепляем линию к курсоруif(id == CHARTEVENT_MOUSE_MOVE)
if(ObjectMove(0,line_name,0,0,price))
ChartRedraw(0);
}
}elseif(ObjectFind(line_name) == window) Print(ObjectDelete(line_name));
//Если нажать Esc то удалится линия и кнопка отожметсяif(id == CHARTEVENT_KEYDOWN && lparam == 27){
button_name = "Button Stop Order";
ms=GetMicrosecondCount();
}
}
//----------------------------------------------------------------------void CreateLine(conststring name, constcolor clr)
{
Print(ObjectCreate(0, name, OBJ_HLINE, 0,0,0));
ObjectSetInteger(0, name, OBJPROP_COLOR, clr);
ObjectSetInteger(0, name, OBJPROP_STYLE, 3);
}
MakarFX #: I have it created and so do you, only the price is "0".
Yes indeed 8 pieces, but it is not visible on the chart, the fact that the price is 0 does not matter, the line still clings to the cursor (follows it)
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.
No Makar, it looks like this:
The ObjectFind() function returns the number of the main window. And this number is 0. On the other hand, 0 == false, so it follows that if the function returns 0, it still returns false. Of course, I would not use this because if the function returns -1, i.e. an error, we may consider the location of the object not in the main window. On top of that, you never know what fixes will be made...
So don't argue and don't study how to do it...
The ObjectFind() function does not return the number of the main window. It will return the number of window where the object was found (0, 1, 2...) or -1 if the object doesn't exist.
I wonder if "-1" is false or true.
The booltype is used to store the boolean values true or false, with a numeric representation of 1 or 0 respectively .The ObjectFind() function does not return the main window number. It is the number of window where the object is found (0,1,2...) or -1 if there is no object.
I was talking about specific case where object is located in main window. Don't argue and don't learn how to do it...
MakarFX #:
I wonder if "-1" is false or true?
The booltype is intended to store the boolean values true or false, whose numeric representation is 1 or 0, respectively .false is only 0. Everything else is true
false is only 0. Everything else is true
No Makar, it looks like this:
The ObjectFind() function returns the number of the main window. And this number is 0. On the other hand, 0 == false, so it follows that if the function returns 0, it still returns false. Of course, I would not use this because if the function returns -1, i.e. an error, we may consider the location of the object not in the main window. On top of that, you never know what fixes will be made...
So don't argue and don't learn how to do it...
I realize that you should not do so, but I had to for the sake of aesthetics (== 0 in every condition looks ugly). And I only need the object in the main window.
I know I shouldn't do this, but I had to for the sake of aesthetics (== 0 in every condition looks ugly). And I only need the object in the main window.
Then do the following
if there is no object, you'll get "-1", i.e. true
Problem: Yellow and grey lines ("Stop Sell" and "not allowed") are constantly created and flickering when the button is pressed on the chart. And ObjectCreate() constantly returns true instead of false, i.e. it creates as if in another window and that could explain the flickering... But the window is only the main one and there are no anomalies with the green line ("Buy Stop") as well as with the red one ("Stop Loss").
Then do the following
if there is no object, you get "-1", i.e. true
I've tried it, I just need to change object names (invert) for the exception to work. But this way no lines are created at all.
I've tried it, only you have to change the name of the objects. But this doesn't create any lines at all.
I have it created and so do you, only the price is "0".