Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1464

 
SuhanovDM94 create an indicator that will read a file with USDTRY quotes from shared memory, then calculate the spread and draw it on this "single" chart as a regular line. I haven't thought of anything better yet. Thanks for the tips, everyone!)

Read: https://www.mql5.com/ru/articles/115

Реализация взаимодействия между клиентскими терминалами MetaTrader 5 при помощи именованных каналов (Named Pipes)
Реализация взаимодействия между клиентскими терминалами MetaTrader 5 при помощи именованных каналов (Named Pipes)
  • www.mql5.com
Данная статья знакомит с реализацией межпроцессного взаимодействия между терминалами MetaTrader 5 посредством именованных каналов (named pipes). Предложен класс CNamedPipes, реализующий возможность использования именованных каналов. Рассмотрен тиковый индикатор для тестирования связи между двумя клиентскими терминалами MetaTrader 5 и измерения общей пропускной способности системы. Представленный метод взаимодействия оказался пригодным для отправки котировок в реальном времени.
 
Связь с MetaTrader 5 через именованные каналы без применения DLL
Связь с MetaTrader 5 через именованные каналы без применения DLL
  • www.mql5.com
Перед многими разработчиками встает одинаковая проблема - как пробиться в песочницу торгового терминала без применения небезопасных DLL. Одним из простых и безопасных методов является использование стандартных именованных каналов (Named Pipes), которые работают как обычные файловые операции. Они позволяют организовать межпроцессорное клиент-серверное взаимодействие между программами. Посмотрите практические примеры на C++ и MQL5 в виде сервера, клиента, обмен данными между ними и замер производительности.
 
Artyom Trishkin #:
And also: https://www.mql5.com/ru/articles/503
Thank you very much!
 

Good afternoon!

Could you please tell me why forward testing is necessary?

Isn't it equivalent to simple optimisation on a full interval?
 

Good afternoon programmers! Please help me with a script. I need the script to draw a multitude of vertical lines on the chart for a list of dates. That is, for example: I enter in the body of the code, a list of 100 dates for example, and the script just draws a vertical line for each date.

I started to try something here, but somehow it turns out to be very cumbersome, and it is only one line.

#property strict
//--- описание
#property description "Скрипт строит графический объект \"Вертикальная линия\"."
#property description "Дата точки привязки задается в процентах от ширины"
#property description "окна графика в барах."
//--- покажем окно входных параметров при запуске скрипта
#property script_show_inputs
//--- входные параметры скрипта
input string          InpName="VLine";     // Имя линии
input int             InpDate=25;          // Дата линии в %
input color           InpColor=clrRed;     // Цвет линии
input ENUM_LINE_STYLE InpStyle=STYLE_DASH; // Стиль линии
input int             InpWidth=3;          // Толщина линии
input bool            InpBack=false;       // Линия на заднем плане
input bool            InpSelection=true;   // Выделить для перемещений
input bool            InpHidden=true;      // Скрыт в списке объектов
 
//+------------------------------------------------------------------+
//| Создает вертикальную линию                                       |
//+------------------------------------------------------------------+
bool VLineCreate(const long            chart_ID=0,        // ID графика
                 const string          name="VLine",      // имя линии
                 const int             sub_window=0,      // номер подокна
                 datetime              time=0,            // время линии
                 const color           clr=clrRed,        // цвет линии
                 const ENUM_LINE_STYLE style=STYLE_SOLID, // стиль линии
                 const int             width=1,           // толщина линии
                 const bool            back=false,        // на заднем плане
                 const bool            selection=true,    // выделить для перемещений
                 const bool            hidden=true)       // скрыт в списке объектов
           
  {
//--- если время линии не задано, то проводим ее через последний бар

      time=TimeCurrent();


 ObjectCreate(chart_ID,name,OBJ_VLINE,sub_window,time,0);
    
     
     
//--- установим цвет линии
   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);
 
   return(true);
  }
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
 

 
 datetime time=TimeCurrent();
      
//--- создадим вертикальную линию
VLineCreate(0,InpName,0,time,InpColor,InpStyle,InpWidth,InpBack,
      InpSelection,InpHidden);
      
return;
 }
 
Alexey Belyakov #:

Good afternoon programmers! Please help me with a script. I need the script to draw a multitude of vertical lines on the chart for a list of dates. That is, for example: I enter in the body of the code, a list of 100 dates for example, and the script just draws a vertical line for each date.

I started to try something here, but somehow it turns out to be very cumbersome, and it is only one line.

The date in string through the separator.

Then split this string into an array.

Then loop through the array at each iteration by calling

VLineCreate
 

Thank you. Since I'm a very superficial programmer. I'll start asking in order.

"Put the date in string with a delimiter."

Use " string TimeToString( ""

????

 
Alexey Belyakov TimeToString( ""

????

You don't need to convert anything to string to draw a line.

You described the problem, but you didn't describe it completely, so people have to figure it out.

How are you going to record 100 dates?

Are you going to write them in the body of the script?

datetime time1 = D'2021.11.15 00:00:00';
datetime time2 = D'2022.11.15 00:00:00';
datetime time3 = D'2023.11.15 00:00:00';
// в этом случае так делаем
VLineCreate(0, InpName, 0, time1, InpColor, InpStyle, InpWidth, InpBack, InpSelection, InpHidden);
VLineCreate(0, InpName, 0, time2, InpColor, InpStyle, InpWidth, InpBack, InpSelection, InpHidden);
VLineCreate(0, InpName, 0, time3, InpColor, InpStyle, InpWidth, InpBack, InpSelection, InpHidden);

Or will you enter them manually when launching the Expert Advisor?

input datetime time1 = D'2021.11.15 00:00:00';
input datetime time2 = D'2022.11.15 00:00:00';
input datetime time3 = D'2023.11.15 00:00:00';
//в этом случае можно сделать так или без массива прописать функцию линии для каждой даты как написано выше
void OnStart(void)
  {
   datetime time[100];

   time[0] = time1;
   time[1] = time2;
   time[2] = time3;

   for(int i = 0; i < 3; i++)
      VLineCreate(0, "InpName" + (string)i, 0, time[i], InpColor, InpStyle, InpWidth, InpBack, InpSelection, InpHidden);
  }
 
Aleksandr Slavskii #:

You don't need to convert anything to string to draw a line.

You have described the task, but you have not described it completely, so people have to guess.

How are you going to record 100 dates?

Are you going to write them in the body of the script?

or will you enter them manually when launching the Expert Advisor?

I checked. The second case is good, but it is not suitable because of the need to enter each date into the window manually, which is time-consuming. It should be simple... "ctrl-c, ctrl-v".

In the first case, for some reason it does not draw 3 lines, but only one, on the most recent candle. Why, it is not clear yet, I'm looking into it.

 
Alexey Belyakov #:

Checked. The second case is good, but it is not suitable because of the need to enter each date into the window manually, time-consuming. It should be simple... "ctrl-c, ctrl-v."

In the first case, for some reason it does not draw 3 lines, but only one, on the most recent candle. Why, it is not clear yet, I'm looking into it.

The line name should be unique. I missed this point

Reason: