Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 823

 
tara:

Thank you, but the problem hasn't gone away.

 

Can anyone suggest whether these expressions are equivalent or not?

1) double BarN=NormalizeDouble(iHigh(Symbol(),5,iHighest(Symbol(),5,MODE_HIGH,num,1)),Digits) 

2) double BarN=NormalizeDouble(High[iHighest(Symbol(),5,MODE_HIGH,num,1)],Digits)
 
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                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   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(const long              chart_ID=0,           // ID графика
                     const string            name="ArrowDown",     // имя знака
                     const int               sub_window=0,         // номер подокна
                     datetime                time=0,               // время точки привязки
                     double                  price=0,              // цена точки привязки
                     const ENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // способ привязки
                     const color             clr=clrRed,           // цвет знака
                     const ENUM_LINE_STYLE   style=STYLE_SOLID,    // стиль окаймляющей линии
                     const int               width=3,              // размер знака
                     const bool              back=false,           // на заднем плане
                     const bool              selection=true,       // выделить для перемещений
                     const bool              hidden=true,          // скрыт в списке объектов
                     const long              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(const long              chart_ID=0,           // ID графика
                   const string            name="ArrowUp",       // имя знака
                   const int               sub_window=0,         // номер подокна
                   datetime                time=0,               // время точки привязки
                   double                  price=0,              // цена точки привязки
                   const ENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // способ привязки
                   const color             clr=clrRed,           // цвет знака
                   const ENUM_LINE_STYLE   style=STYLE_SOLID,    // стиль окаймляющей линии
                   const int               width=3,              // размер знака
                   const bool              back=false,           // на заднем плане
                   const bool              selection=true,       // выделить для перемещений
                   const bool              hidden=true,          // скрыт в списке объектов
                   const long              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);
  }
//+------------------------------------------------------------------+
 
P./S.: Corrected the line in my post above now, replacing ANCHOR_BOTTOM with ANCHOR_TOP:
 if(ObjectFind(0,"Покупка")<0)
     {
      ArrowUpCreate(0,"Покупка",0,Time[1],Low[1],
                    ANCHOR_TOP,clrGreen,STYLE_SOLID,5,false,false,true,0);
     }
 
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?
Add time to the name of the object.
 
Veterros:

Yes. The individual name can be spelled in different ways.

For example, the function for forming individual names for objects can look like this:

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string nameNi(string PrefixN, datetime TimeN)
  {
   string textn=NULL;
   textn=StringConcatenate(PrefixN,TimeToString(TimeN,TIME_DATE|TIME_MINUTES));
   return (textn);
  }

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

if(ObjectFind(0,nameobj)<0)
     {
      ArrowDownCreate(0,nameobj,0,timeX,HiN,
                      ANCHOR_BOTTOM,clrRed,STYLE_SOLID,5,false,false,true,0);
     }


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.

 
evillive:
Add the time to the name of the object.
Thank you very much!
 
DiPach:

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 ;).

 
artmedia70:

Artyom, you're back on the site!!! Hooray!!! Insanely glad to see you here!!!! )))

I'll go and see hello from Lyova now! )))

Reason: