Veterros: Can you guys tell me why 4202 gives out (Object does not exist). Correct, it does not exist, it must be created, but it me (does not exist)! What can be done with it? Or I screwed up somewhere else?
I hastily tried your version as a script, replacing the time and marks and checking for objects, but it did not return errors.
Maybe, to save the trouble, try to form arrow objects considering the new MQL4 language?
Here is the "body" for the script that creates the arrow-objects you specified, taking into account the new language (the times and marks are arbitrary, instead of SignalBarsTime, Hi2, SignalBarsTime, Lo2, which you know only so far):
//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
//---if(ObjectFind(0,"Продажа")<0)
{
ArrowDownCreate(0,"Продажа",0,Time[2],High[2],
ANCHOR_BOTTOM,clrRed,STYLE_SOLID,5,false,false,true,0);
}
if(ObjectFind(0,"Покупка")<0)
{
ArrowUpCreate(0,"Покупка",0,Time[1],Low[1],
ANCHOR_TOP,clrGreen,STYLE_SOLID,5,false,false,true,0);
}
}
//+------------------------------------------------------------------+//| Создает знак "Стрелка вниз" https://docs.mql4.com/ru/constants/objectconstants/enum_object/obj_arrow_down//+------------------------------------------------------------------+bool ArrowDownCreate(constlong chart_ID=0, // ID графикаconststring name="ArrowDown", // имя знакаconstint sub_window=0, // номер подокнаdatetime time=0, // время точки привязкиdouble price=0, // цена точки привязкиconstENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // способ привязкиconstcolor clr=clrRed, // цвет знакаconstENUM_LINE_STYLE style=STYLE_SOLID, // стиль окаймляющей линииconstint width=3, // размер знакаconstbool back=false, // на заднем планеconstbool selection=true, // выделить для перемещенийconstbool hidden=true, // скрыт в списке объектовconstlong z_order=0) // приоритет на нажатие мышью
{
//--- установим координаты точки привязки, если они не заданы//ChangeArrowEmptyPoint(time,price);//--- сбросим значение ошибкиResetLastError();
//--- создадим знакif(!ObjectCreate(chart_ID,name,OBJ_ARROW_DOWN,sub_window,time,price))
{
Print(__FUNCTION__,
": не удалось создать знак \"Стрелка вниз\"! Код ошибки = ",GetLastError());
return(false);
}
//--- способ привязкиObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- установим цвет знакаObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- установим стиль окаймляющей линииObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- установим размер знакаObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- отобразим на переднем (false) или заднем (true) планеObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- включим (true) или отключим (false) режим перемещения знака мышью//--- при создании графического объекта функцией ObjectCreate, по умолчанию объект//--- нельзя выделить и перемещать. Внутри же этого метода параметр selection//--- по умолчанию равен true, что позволяет выделять и перемещать этот объектObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- скроем (true) или отобразим (false) имя графического объекта в списке объектовObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- установим приоритет на получение события нажатия мыши на графикеObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- успешное выполнениеreturn(true);
}
//+------------------------------------------------------------------+//| Создает знак "Стрелка вверх" https://docs.mql4.com/ru/constants/objectconstants/enum_object/obj_arrow_up//+------------------------------------------------------------------+bool ArrowUpCreate(constlong chart_ID=0, // ID графикаconststring name="ArrowUp", // имя знакаconstint sub_window=0, // номер подокнаdatetime time=0, // время точки привязкиdouble price=0, // цена точки привязкиconstENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // способ привязкиconstcolor clr=clrRed, // цвет знакаconstENUM_LINE_STYLE style=STYLE_SOLID, // стиль окаймляющей линииconstint width=3, // размер знакаconstbool back=false, // на заднем планеconstbool selection=true, // выделить для перемещенийconstbool hidden=true, // скрыт в списке объектовconstlong z_order=0) // приоритет на нажатие мышью
{
//--- установим координаты точки привязки, если они не заданы//ChangeArrowEmptyPoint(time,price);//--- сбросим значение ошибкиResetLastError();
//--- создадим знакif(!ObjectCreate(chart_ID,name,OBJ_ARROW_UP,sub_window,time,price))
{
Print(__FUNCTION__,
": не удалось создать знак \"Стрелка вверх\"! Код ошибки = ",GetLastError());
return(false);
}
//--- установим способ привязкиObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- установим цвет знакаObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- установим стиль окаймляющей линииObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- установим размер знакаObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- отобразим на переднем (false) или заднем (true) планеObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- включим (true) или отключим (false) режим перемещения знака мышью//--- при создании графического объекта функцией ObjectCreate, по умолчанию объект//--- нельзя выделить и перемещать. Внутри же этого метода параметр selection//--- по умолчанию равен true, что позволяет выделять и перемещать этот объектObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- скроем (true) или отобразим (false) имя графического объекта в списке объектовObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- установим приоритет на получение события нажатия мыши на графикеObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- успешное выполнениеreturn(true);
}
//+------------------------------------------------------------------+
DiPach: P./S.: Corrected the line in my post above now, replacing ANCHOR_BOTTOM with ANCHOR_TOP:
Thank you very much, very helpful. I'd still like to find a way to make the names of the objects to be assigned automatically, I have to redraw them every time. Maybe advise where to learn about it and in what area to look?
Veterros: Thank you very much, that's very helpful. I'd like to find out how to name objects automatically, because I have to redraw them every time. Maybe you can tell me where to find out about it and where to look?
Now I can't think where exactly you can look it up in help or search the site, but the tutorial reminded me of this page: https://book.mql4.com/ru/functions/strings
There you can find information and a code sample. Just use TimeToString instead of TimeToStr. However, it can be of great help when mastering the new MQL4 language. Also in combination with the help for the updated language.
Yes. The individual name can be spelled in different ways.
For example, the function for forming individual names for objects can look like this:
And in the body of the program it can be output like this (having written beforehand in conditions what will serve as a prefix):
Further, for a newly created object it could look like this
Now I can't think where exactly you can look it up in help or search the site, but the tutorial reminded me of this page: https://book.mql4.com/ru/functions/strings
There you can find information and a code sample. Just use TimeToString instead of TimeToStr. However, it can be of great help when mastering the new MQL4 language. Also in combination with the help for the updated language.
Hi, darling ;) Imagine, how long I've been writing code for different objects and I've never thought of making a separate function to create names - I've always done it directly in the code. I've been working too hard. Thanks for the tip. And everywhere else, where relevant, for compactness, I write the functions, but here something tormented all the time.
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.
Thank you, but the problem hasn't gone away.
Can anyone suggest whether these expressions are equivalent or not?
Can you guys tell me why 4202 gives out (Object does not exist). Correct, it does not exist, it must be created, but it me (does not exist)! What can be done with it? Or I screwed up somewhere else?
I hastily tried your version as a script, replacing the time and marks and checking for objects, but it did not return errors.
Maybe, to save the trouble, try to form arrow objects considering the new MQL4 language?
Here is the "body" for the script that creates the arrow-objects you specified, taking into account the new language (the times and marks are arbitrary, instead of SignalBarsTime, Hi2, SignalBarsTime, Lo2, which you know only so far):
P./S.: Corrected the line in my post above now, replacing ANCHOR_BOTTOM with ANCHOR_TOP:
Thank you very much, that's very helpful. I'd like to find out how to name objects automatically, because I have to redraw them every time. Maybe you can tell me where to find out about it and where to look?
Yes. The individual name can be spelled in different ways.
For example, the function for forming individual names for objects can look like this:
And in the body of the program it can be output like this (having written beforehand in conditions what will serve as a prefix):
... string nameobj=nameNi(prefixX,timeX);Further, for a newly created object it could look like this
Now I can't think where exactly you can look it up in help or search the site, but the tutorial reminded me of this page: https://book.mql4.com/ru/functions/strings
There you can find information and a code sample. Just use TimeToString instead of TimeToStr. However, it can be of great help when mastering the new MQL4 language. Also in combination with the help for the updated language.
Add the time to the name of the object.
Yes. The individual name can be spelled in different ways.
For example, the function for forming individual names for objects can look like this:
And in the body of the program it can be output like this (having written beforehand in conditions what will serve as a prefix):
Further, for a newly created object it could look like this
Now I can't think where exactly you can look it up in help or search the site, but the tutorial reminded me of this page: https://book.mql4.com/ru/functions/strings
There you can find information and a code sample. Just use TimeToString instead of TimeToStr. However, it can be of great help when mastering the new MQL4 language. Also in combination with the help for the updated language.
Hi, darling ;) Imagine, how long I've been writing code for different objects and I've never thought of making a separate function to create names - I've always done it directly in the code. I've been working too hard. Thanks for the tip. And everywhere else, where relevant, for compactness, I write the functions, but here something tormented all the time.
ZS. There you have said hello Lyov ;).
Artyom, you're back on the site!!! Hooray!!! Insanely glad to see you here!!!! )))
I'll go and see hello from Lyova now! )))