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

 
ANDREY:

Do I understand correctly, that now in mql4 the arrays should be initialized only using the function

Not necessarily, but it's better to check such questions with test scripts:

void OnStart()
{
   int arr_1[10] = {123};
   int arr_2[10] = {0,1,2,3,4,5,6,7,8,9};
   int arr_3[10];
   ArrayInitialize(arr_3,777);
   ArrayPrint(arr_1);   // 123   0   0   0   0   0   0   0   0   0
   ArrayPrint(arr_2);   // 0 1 2 3 4 5 6 7 8 9
   ArrayPrint(arr_3);   // 777 777 777 777 777 777 777 777 777 777
}
ANDREY:

Kovalev's tutorial says that you can initialize an array simultaneously with its declaration (as I did), without any special function.

Your variant in my example arr_1 - so you can initialize it with a null value! - and if another one, then the first element of the array will be an initialization value, and all the rest will be null.

I think the tutorial advised you to initialise as in my example arr_2

 

Afternoon.

You need to visualise in your EA the values of the indicator used in it. You do not have to draw it exactly as it looks. It is quite enough to mark the point value of the indicator on each candlestick. I have tried to do it through the object OBJ_ARROW and found out that the anchor point cannot be in the centre of the object. It is either higher or lower than the object. As a result, the points do not coincide with the real values of the indicator. Can you suggest a solution to this problem.

indicator display via OBJ_ARROW

 
Oleg Remizov:

Afternoon.

You need to visualise in your EA the values of the indicator used in it. You do not have to draw it exactly as it looks. It is quite enough to mark the point value of the indicator on each candlestick. I have tried to do it through the object OBJ_ARROW and found out that the anchor point cannot be in the centre of the object. It is either higher or lower than the object. As a result, the points do not coincide with the real values of the indicator. Suggest a solution to this problem.

Create a template with all required indicators and save it with name tester or with name of Expert Advisor.

 
Alexey Viktorov:

Create a template with all the indicators you want and save it with the name tester or with the name of the EA.

Unfortunately, the template will not work for me. It is necessary to enable/disable the function to display the indicators in the settings, and the drawing should be done directly from the EA. The EA should be able to be transferred in one file.

 
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. I want to be able to transfer the EA in one file.

These are strange wishes. If you want your EA to work, just work, then it is enough to attach it as a resource and it will not need any displaying and will work without indicator's file. And if you want exactly the displaying, what is the point of not giving the indicator file?

 
Alexey Viktorov:

This is a strange request. If you want the EA to work, just work, then it is enough to attach it as a resource and it will work without the indicator file. If you want to see the exact mapping, what is the point of not giving the indicator file?

It's not that I don't want to give an indicator file. An Expert Advisor that requires additional files cannot be published on the Market. In fact, it's convenient to have everything you need for your work in one file.

Besides, I don't always need to show all indicator buffers if there are a few of them. For example, I have an indicator for Ishimoku. It has 5 lines but only one of them should be selected for using in an Expert Advisor. I want to display only one of them instead of the entire indicator.

 
Igor Makanu:

not necessarily, but it is better to check such questions with test scripts:

Your variant in my example arr_1 - so you can initialize with a null value! - and if the other one, then the first element of the array will be an initialisation value and all the others will be null.

I think the tutorial advised you to initialize as in my example arr_2

Thanks for the valuable information for me.

 
Oleg Remizov:

It's not that I don't want to give an indicator file. An Expert Advisor that requires additional files cannot be published on the Market. And in general, it is convenient to have everything you need for work in one file.

Besides, I don't always need to show all indicator buffers if there are a few of them. For example, I have an indicator for Ishimoku. It has 5 lines but only one of them should be selected for using in an Expert Advisor. This is the only one we want to display and not the entire indicator.

Well, the indicators are used as a resource for the Market. But what for does the user need it? No one is interested in the principles by which the positions are opened. If you want, you can describe the whole strategy in the description. Does anybody need it?

 
Igor Makanu:


I think the textbook advised you to initialize as in my example arr_2

Here is what the Kovalev textbook says about initializing an array at the same time as declaring it

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 tutorial, I would appreciate if you could tell me what I've misunderstood.

 
Alexey Viktorov:

Well, that's what they use the indicators as a resource for the marketplace. But what do the users need it for? No one is interested in the principles by which positions are opened. If you want, you may describe the whole strategy in the description. Does anyone need it?

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

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