Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1238

 
Oleg Remizov:

And according to my observations, users like it when the Expert Advisor displays various information on the screen: it draws arrows, lines, channels and other things to show the vigorous activity of the "artificial intelligence").

According to the indicators, the Expert Advisor provides trailing. I want to visualize this process so that a user could see the dotted line with StopLoss.

Use a Trend line, the first anchor point is the current bar and the second one is 1 bar in history, put the thickness of 2-3

 
Vitaly Muzichenko:

Use a trend line, first anchor point current bar and second 1 bar into history, put the thickness at 2-3

Great idea! Thank you very much, looks just right.

trending

 
ANDREY:

Here is what it says in Kovalev's textbook about initializing an array at the same time as it is declared

8.4.4 Array initialization

An array can be initialized only with constants of the appropriate type.One-dimensional and multidimensional arrays are initialized with a one-dimensional sequence of constants listed separated by commas. The sequence is enclosed in curly braces:

int Mas_i[3][4] = { 0, 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23 }

double Mas_d[2][3] = { 0.1, 0.2, -0.3, -10.2, 1.5, 7.0 };

bool Mas_b[5] = { false, true, false, true, true }

One or more constants may be skipped in the initializing sequence.

It seems to me from the textbook that when an array is declared, the full array is initialized with all the data, not only the first element of the array.
If I've misunderstood the textbook, I would be grateful if you could point out what I've misunderstood.

I don't have the slightest desire to discuss your textbook, I haven't read it

and wrote here on the forum that the textbook is outdated and irrelevant.

a two dimensional array can be initialised that way:

int arr[2][5] = {{1, 2, 3, 4, 5,}, {6, 7, 8, 9, 10}};
 
Igor Makanu:

not the slightest desire to discuss your textbook, I haven't read it

and have written here on the forum that the textbook is outdated and irrelevant.

A two dimensional array can be initialised that way:

Thank you very much for your help. You have directly guessed my thoughts. I'm just puzzling over how to initialize a two-dimensional array.....but only by means of functionArrayInitialize();
The manual of this function gives information about initialization only of one-dimensional array, as it seemed to me.
I will be very grateful, if you tell me.

 
ANDREY:

Thank you very much for your help. You have directly guessed my thoughts. I am just puzzling over how to initialize two-dimensional array.....but only by means of function ArrayInitialize ();
In the reference on this function the information about initialization only one-dimensional array is given, as it seemed to me.
I will be very grateful, if you tell me.

ArrayFill() allows you to fill all elements of an array with the desired value and can be used for a two-dimensional array. Look at the example in the help for this function.

By the way, I checkedArrayInitialize() applied to a two-dimensional array, it works too. But in both cases you can initialize only all elements with a particular value.

If you need to set a different value for each element, these functions will not work.

Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Переменные должны быть объявлены перед их использованием. Для идентификации переменных используются уникальные имена. Описания переменных используются для их определения и объявления типов. Описание не является оператором. Индексом массива может быть только целое число. Допускаются не более чем четырехмерные массивы. Нумерация элементов массива...
 
Oleg Remizov:

ArrayFill() allows you to fill all the elements of an array with the desired value and can be used for a two-dimensional array. See the example in the help for this function.

By the way, I checkedArrayInitialize() applied to a two-dimensional array, it works too. Except that in both cases you can initialize only all elements with a particular value.

If you need to set a different value for each item, these functions will not work.

Thank you very much for your help.

 
Oleg Remizov:

Unfortunately, the template will not work for me. The indicator display function should be switched on/off in the settings, and the drawing should be done directly from the EA. The Expert Advisor should be able to be transferred in one file.

Instead of the arrow, draw a trend line, which has the same price and time at both points. Use the thickness of the line to adjust the size of the resulting point.

 
Hello, I am a newcomer and would like to know how to withdraw money from my account and then when to transfer it
 

Greetings.

There is a thing like this in MT4:

#import "user32.dll"
   int SendMessageA(int hWnd, int Msg, int wParam, char &lParam[]);
   int RegisterWindowMessageA(uchar &lParam[]);
#import

string IndiName="TestBot";

void OnStart()
  {
   char buf[];
   StringToCharArray("MetaTrader4_Internal_Message", buf);
   int MT4InternalMsg=RegisterWindowMessageA(buf);
   StringToCharArray(IndiName, buf);
   long handle=ChartGetInteger(0, CHART_WINDOW_HANDLE);
   Print(MT4InternalMsg);
   bool res=SendMessageA((int)handle, MT4InternalMsg, 14, buf);
   Print("Функция SendMessageA завершила работу с результатом: ",res);
  }

This code sends a command to the terminal window to run a specific EA.

Is there a similar functionality for MT5 ?

I tried it like this:

#import "user32.dll"
   int SendMessageA(long hWnd, long Msg, uint wParam, uchar &lParam[]);
   int RegisterWindowMessageA(uchar &lParam[]);
#import

string IndiName="TestBot";

void OnStart()
  {
   uchar buf[];
   StringToCharArray("MetaTrader5_Internal_Message", buf);
   long MT5InternalMsg=RegisterWindowMessageA(buf);
   StringToCharArray(IndiName, buf);
   long handle=ChartGetInteger(0, CHART_WINDOW_HANDLE);
   Print("Window handle: ", handle);
   Print("Message: ",MT5InternalMsg);
   for(int i = 0; i<100; i++){
      bool res=SendMessageA(handle, MT5InternalMsg, i , buf);
      printf("Функция SendMessageA завершила работу с результатом: %d, номер: %d ",res, i);
   }
  }

Doesn't work.

I tried scanning for spy++, but there are no messages in MT5 unlike in MT4.

I need exactly to call the Expert Advisor settings window.

 
50211108:
Hello, I am a Newbie and would like to clarify how to withdraw money from the account and then when to deposit

You can only withdraw what you have earned from this resource, which is the sale of software, signals and computer power. What is entered can only be spent on this resource.

Reason: