Questions from a "dummy" - page 30

 
Silent:

It is unclear why it works at all.

The correct example is at the bottom of the page

There is also a search first, and redrawing - I saw somewhere that it's better to be safeguarded.

// Don't beat me, I'm learning it myself.

Haven't really looked into it, but it seems to be pretty normal code at first glance.

Silent:

I have highlighted errors, because of which the code does not seem to work. Compare your code to the one in the sample by the link.

Maybe I'm blind, but where exactly are the errors?
 
Interesting:
I don't understand it but the code seems fine at first glance.
Maybe I'm blind, but where exactly are the errors?

In my post it is highlighted in red - there are no values for chart id, anchor point, anchor angle (what is it for, if we don't rotate the picture?), coordinates.

 
Silent:

In my post in the code it is highlighted in red - there are no values for chart id, anchor point, anchor angle (what is it for, if we don't rotate the picture?), and coordinates.

And I thought I was the beginner)))) This is a function. Values are transferred to it.))
 
tol64:
And I thought I was the most novice.)) It's a function. Values are passed into it.)
Where do the values come from?
 
Silent:
Where do the values come from?

From anywhere. External parameters, global variables, local variables. Or you can write values at once.

Example:

Create_BMP_Label(0,TS_bmp_nm,TS_bmp_pth,ANCHOR_RIGHT_UPPER,CORNER_RIGHT_UPPER,x,y+50);
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
  • www.mql5.com
Основы языка / Переменные / Глобальные переменные - Документация по MQL5
 
tol64:

From anywhere. External parameters, global variables, local variables. Alternatively, values can be written in immediately.

In your code, from where?
 
Silent:

In my post, in the code marked red - no values for chart id, anchor point, anchor angle (what for, if you don't rotate the picture?), or coordinates.

1. About Id - there should be no values there (as I understand it is expected to be default 0), and what is written in the commentary is most likely "for yourself".

2. About Angles Binding - Binding goes to a particular corner of the graffiti (left-top, right-top, bottom-right and bottom-left). By specifying these parameters we determine what corner the object is anchored to.

This code will create a LABEL at the bottom-right corner

ObjectCreate(0,"Demo",OBJ_LABEL,0,0,1.0);
ObjectSetInteger(0,"Demo",OBJPROP_TIMEFRAMES,OBJ_ALL_PERIODS);
ObjectSetInteger(0,"Demo",OBJPROP_CORNER,CORNER_RIGHT_LOWER);
ObjectSetInteger(0,"Demo",OBJPROP_ANCHOR,ANCHOR_RIGHT_LOWER);
ObjectSetInteger(0,"Demo",OBJPROP_XDISTANCE,3);
ObjectSetInteger(0,"Demo",OBJPROP_YDISTANCE,1);
ObjectSetString(0,"Demo",OBJPROP_FONT,"Times New Roman");
ObjectSetInteger(0,"Demo",OBJPROP_FONTSIZE,8);
ObjectSetInteger(0,"Demo",OBJPROP_COLOR,Tomato);
ObjectSetInteger(0,"Demo",OBJPROP_SELECTABLE,false);
ObjectSetString(0,"Demo",OBJPROP_TEXT,m_text);

And this one will display the same object but in the left-bottom corner

ObjectCreate(0,"Demo",OBJ_LABEL,0,0,1.0);
ObjectSetInteger(0,"Demo",OBJPROP_TIMEFRAMES,OBJ_ALL_PERIODS);
ObjectSetInteger(0,"Demo",OBJPROP_CORNER,CORNER_LEFT_LOWER);
ObjectSetInteger(0,"Demo",OBJPROP_ANCHOR,ANCHOR_LEFT_LOWER);
ObjectSetInteger(0,"Demo",OBJPROP_XDISTANCE,3);
ObjectSetInteger(0,"Demo",OBJPROP_YDISTANCE,1);
ObjectSetString(0,"Demo",OBJPROP_FONT,"Times New Roman");
ObjectSetInteger(0,"Demo",OBJPROP_FONTSIZE,8);
ObjectSetInteger(0,"Demo",OBJPROP_COLOR,Tomato);
ObjectSetInteger(0,"Demo",OBJPROP_SELECTABLE,false);
ObjectSetString(0,"Demo",OBJPROP_TEXT,m_text);

As many of you have already understood, only two lines have changed - these

ObjectSetInteger(0,"Demo",OBJPROP_CORNER,CORNER_LEFT_LOWER);
ObjectSetInteger(0,"Demo",OBJPROP_ANCHOR,ANCHOR_LEFT_LOWER);
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки - Документация по MQL5
 
Silent:
In your code - where from?
Not pincially, it will draw in normal mode if the values are correct. In render mode, there will probably be problems with BMP-graphics (I'm about 90% sure).
 
Silent:
In your code, from where?

From global variables (highlighted in red).

Create_BMP_Label(0,TS_bmp_nm,TS_bmp_pth,ANCHOR_RIGHT_UPPER,CORNER_RIGHT_UPPER,x,y+50);
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
  • www.mql5.com
Основы языка / Переменные / Глобальные переменные - Документация по MQL5
 
tol64:

From global variables (highlighted in red).

Initialization - inside the function, values - from global? Hmm.

From the help, for comparison

#define  UP          "\x0431"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   string label_name="my_OBJ_LABEL_object";
   if(ObjectFind(0,label_name)<0)
     {
      Print("Object ",label_name," not found. Error code = ",GetLastError());
      //--- создадим объект Label
      ObjectCreate(0,label_name,OBJ_LABEL,0,0,0);           
      //--- установим координату X
      ObjectSetInteger(0,label_name,OBJPROP_XDISTANCE,200);
      //--- установим координату Y
      ObjectSetInteger(0,label_name,OBJPROP_YDISTANCE,300);
      //--- зададим цвет текста
      ObjectSetInteger(0,label_name,OBJPROP_COLOR,clrWhite);
      //--- установим текст для объекта Label
      ObjectSetString(0,label_name,OBJPROP_TEXT,UP);
      //--- установим шрифт надписи
      ObjectSetString(0,label_name,OBJPROP_FONT,"Wingdings");
      //--- установим размер шрифта
      ObjectSetInteger(0,label_name,OBJPROP_FONTSIZE,10);
      //--- повернем на 45 градусов по часовой стрелке
      ObjectSetDouble(0,label_name,OBJPROP_ANGLE,-45);
      //--- запретим выделение объекта мышкой
      ObjectSetInteger(0,label_name,OBJPROP_SELECTABLE,false);
      //--- отрисуем на графике
      ChartRedraw(0);                                      
     }
  }
Reason: