Questions from Beginners MQL5 MT5 MetaTrader 5 - page 843

 
Sergey Likho:

Thank you.

Can you tell me why OBJ_EDIT may not be displayed on the real chart?

Probably, the binding of objects is set incorrectly, and they have gone beyond the edge of the window.

You'd better specify the binding not 0,1,2 as it is in mt4, butENUM_BASE_CORNER

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки
  • www.mql5.com
Существует ряд графических объектов, для которых можно задавать угол графика, относительно которого указываются координаты в пикселях. Это следующие типы объектов (в скобках указаны идентификаторы типа объекта): – объекты имеет ширину и высоту. Если указано "только для чтения", то это означает, что значения ширины и высоты вычисляются только...
 

Please help me solve the problem, the code works on every tick, so I need the easiest solution.

The problem: There is a pile of closed positions in history, and from this pile we need to extract profit size, which was at the time of last closing, the positions may be from 1 to 100 (grid).

As a rule, they are not closed at the same time, but time difference between opening and closing does not exceed 2 minutes (mt4).

If you expand a loop or an array, everything works, but you cannot expand anything, you have to search from less to more

//+------------------------------------------------------------------+
#property strict

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  datetime tm=0;
  datetime pos[5]={D'2018.04.04 10:07:55',
                   D'2018.04.04 10:08:19',
                   D'2018.04.04 12:08:43',
                   D'2018.04.04 12:08:43',
                   D'2018.04.04 12:08:59'
                  };
  
   for(int i=0; i<5; i++) {
    datetime date=pos[i];
    // ... ld = date;
    // Здесь много кода, и цикл/массив разворачивать нельзя
    // ...
    // 120 секунд разницы между закрытием первой и последней в сетке
    if((tm <= date && date <= tm+120) || tm==0) {
      tm = date;
      Print(i,"=",date); // Ожидаемый результат: 2018.04.04 12:08:59, 2018.04.04 12:08:43, 2018.04.04 12:08:43
    }

   }
    Print("");
    Sleep(10000);
  }
//+------------------------------------------------------------------+
 
Vitaly Muzichenko:

Please help me solve the problem, the code runs on every tick, so I need the easiest solution

Why is the date as text??? This is very unproductive.

 
Vitaly Muzichenko:

Please help me solve the problem, the code runs on every tick, so the easiest solution is needed

  datetime pos[5]={D'2018.04.04 10:07:55',
                   D'2018.04.04 10:08:19',
                   D'2018.04.04 12:08:43',
                   D'2018.04.04 12:08:43',
                   D'2018.04.04 12:08:59'
                  };
 
Vladimir Karputov:

Why is the date in the form of text? It's very unproductive.

This is just an example, in the code everything is normally assembled into an array

P.S. Updated the previous post

P.S. The question is solved, I will expand the array and redo the work of the main code

 

Dear forum users, could you please tell me how to draw a vertical segment between bars without using a rectangular label(OBJ_RECTANGLE_LABEL)? Unfortunately, I haven't found an answer to this question. If there's something I haven't read in the documentation or forum, please point out where. Thank you.

 
MrVIS:

Dear forum users, could you please tell me how to draw a vertical segment between bars without using a rectangular label(OBJ_RECTANGLE_LABEL)? Unfortunately, I haven't found an answer to this question. If there's something I haven't read in the documentation or forum, please point out where. Thank you.

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_TREND
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_TREND
  • www.mql5.com
//| Создает линию тренда по заданным координатам                     |               time1=0,                            price1=0,                         time2=0,                            price2=0,                        width=1,            //| Перемещает точку привязки линии тренда                           | //
 
FelixFX:
I understand that you can learn anything with the help of articles and gestures and facial expressions, but with a textbook, for example, you spend a month learning (without practice), and other ways to spend six months + practice. Not everyone can spend all their free time learning a programming language.

Not really?! And on the contrary. For example, I judge from the past: I had a teacher in mathematics, explained everything in such a way in class that I did not learn a single theorem, but ministerial tests wrote in 15 minutes and for 5; in the eighth grade I was transferred to another teacher and all - the whole class immediately dumbed down. It's the same with textbooks, if I, or someone like me, write them, then your learning time will be very long. And you have been told based on your desire that everything will fall to him and how quickly you will be able to absorb the material. Then you will learn by wandering through the authors and you will have some experience and you will be able to see who and what is withholding. If they teach you to handle a fork and never show you a spoon, you'll be eating soup for a long time. And you'd rather starve than eat it. So go for the mines, and no sappers.

 
MrVIS:

Dear forum users, could you please tell me how to draw a vertical segment between bars without using a rectangular label(OBJ_RECTANGLE_LABEL)? Unfortunately, I haven't found an answer to this question. If there's something I haven't read in the documentation or forum, please point out where. Thank you.

It is quite simple.

Option 1: You draw a horizontal line and rotate the monitor 90° clockwise or anticlockwise.

Option 2. Rotate the position of the MT so that the graph is plotted from the bottom up.

Option 3.

The imagination is broken.

 
Alexey Viktorov:

Simple as that.

Option 1: Draw a horizontal line and rotate the monitor 90° clockwise or anticlockwise.

Option 2. Rotate the position of the MT so that the graph is plotted from bottom to top.

Option 3. ...

The imagination is broken.

Here's a hint: Canvas
Reason: