How do I learn to create graphical objects? MQL4.

 

I've wanted to learn howto create graphical objects for a long time, but many lines of code are confusing.

If everything is clear with calling the indicator in the Expert Advisor: calling the handle, copying values into the buffer, then what is the algorithm for constructing objects in brief?

I will start with the simplest one - drawing the trend line. Here is an examplehttps://www.mql5.com/ru/docs/constants/objectconstants/enum_object/obj_trend

Only, how to make the line appear but not disappear?

I wonder how to read the current position of this line in the EA, there are no buffers in the objects?

I want to create it in MQL4, is it much different from MQL5?

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_TREND
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_TREND
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_TREND - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
TakeOBJ_TREND as an example and copy it into your EA as separate functions. What do you mean by "make it not disappear"? Obtaining object time and price values:ObjectGetTimeByValue andObjectGetValueByTime.
OBJ_TREND - Документация на MQL4
  • docs.mql4.com
OBJ_TREND - Документация на MQL4
 
barabashkakvn:
TakeOBJ_TREND as an example and copy it into your EA as separate functions. What do you mean by "make it not disappear"? Obtaining object time and price values:ObjectGetTimeByValue andObjectGetValueByTime.
When I call the script, the line visually appears (the action happens as in the video) and then disappears.
 
forexman77:
When I call the script, the line appears visually (as in the video) and then disappears.
Change the script code. Remove the deletion of the object. Are you using the whole script from the help?
 
barabashkakvn:
Change the script code. Remove the deletion of the object. Are you using the whole script from the help?
Yes. I'll try it now.
 
barabashkakvn:
Change the script code. Remove the deletion of the object. Are you using the whole script from the help?
The line remains. It's OK. I'll look into it now.
 
If you have any questions about the code, post the code and ask.
 
barabashkakvn:
If you have any questions about the code, post the code and ask.

It is not clear what these numbers mean and what they set? If with time I can assume that it is bar index, then how to understand InpPrice, has int type?

input int             InpDate1=35;         // Дата 1-ой точки в %
input int             InpPrice1=60;        // Цена 1-ой точки в %
input int             InpDate2=65;         // Дата 2-ой точки в %
input int             InpPrice2=40;        // Цена 2-ой точки в %
 
forexman77:

It is not clear what these numbers mean and what they ask?

Deciphering The explanation is given a little above:

#property description "Скрипт строит графический объект \"Трендовая линия\"."
#property description "Координаты точек привязки задаются в процентах от"
#property description "размеров окна графика."

and from here on this data will be used to determine the drawing points:

void OnStart()
  {
.
.
.
//--- определим точки для рисования линии
   int d1=InpDate1*(bars-1)/100;
   int d2=InpDate2*(bars-1)/100;
   int p1=InpPrice1*(accuracy-1)/100;
   int p2=InpPrice2*(accuracy-1)/100;
//--- создадим линию тренда
.
.
.
 
barabashkakvn:

Deciphering The explanation is given a little above:

and from here on this data will be used to define the drawing points:

In the"OBJ_TREND" example, I think there is a lot of unnecessary data. Since I don't know this area very well I'm afraid I'll be lost for a long time.

As far as I understand the code is searched, but I already know the two points, bar indexes (my algorithm).

The only question is how to connect these two points with a line and continue it to the right up to a certain event.

 
forexman77:

There seems to be a lot of redundancy in this example. Since I don't know this area very well, I'm afraid I'll be wandering around for a long time.

As far as I understand the code is searching, but I already know the two points, index bars (my algorithm).

The only question is how to connect these two points with a line and continue it to the right up to a certain event.

If you know the time and dates of your points, you only need to callbool TrendCreate()