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

 
Alekseu Fedotov #:

22:23:17.002 Dynamic EURCAD,H1: +============================+

0 22:23:17.002 Dynamic EURCAD,H1: 1. Checking a dynamic array:

0 22:23:17.002 Dynamic EURCAD,H1: Size before memory release = 100

0 22:23:17.002 Dynamic EURCAD,H1: This is Dynamic Array = Yes

0 22:23:17.002 Dynamic EURCAD,H1: Size after memory free = 0

0 22:23:17.002 Dynamic EURCAD,H1: 2. Static array check:

0 22:23:17.002 Dynamic EURCAD,H1: Size before memory free = 100

0 22:23:17.002 Dynamic EURCAD,H1: This is dynamic array = None

0 22:23:17.002 Dynamic EURCAD,H1: Size after memory free = 0

0 22:23:17.002 Dynamic EURCAD,H1: 3. Check indicator buffer:

0 22:23:17.002 Dynamic EURCAD,H1: Size before memory free = 2725

0 22:23:17.002 Dynamic EURCAD,H1: This is dynamic array = Yes

0 22:23:17.002 Dynamic EURCAD,H1: Size after memory release = 0

0 22:23:24.754 Dynamic EURCAD,H1: uninit reason 1

0 22:23:24.758 Custom indicator Dynamic EURCAD,H1: removed

This is at 4.

Fantastic! What is this magic? I just checked on EURCAD,H1 - again no.

And what is 4? There are only three points in the example.

 
x572intraday #:

Fantastic! What is this magic? Just checked on EURCAD,H1 - "No" again.

And what's 4? There are only three points in the example.

MT4 terminal

 
x572intraday #:

Fantastic! What is this magic? Just checked on EURCAD,H1 - "No" again.

And what's 4? There are only three points in the example.

0 23:33:06.088 test (EURUSD,D1) +============================+

0 23:33:06.088 test (EURUSD,D1) 1. Check of dynamic array:

0 23:33:06.088 test (EURUSD,D1) Size before memory release = 100

0 23:33:06.088 test (EURUSD,D1) This is a dynamic array = Yes

0 23:33:06.088 test (EURUSD,D1) Size after memory release = 0

0 23:33:06.088 test (EURUSD,D1) 2. Static array test:

0 23:33:06.088 test (EURUSD,D1) Size before memory free = 100

0 23:33:06.088 test (EURUSD,D1) This is a dynamic array = None

0 23:33:06.088 test (EURUSD,D1) Size after memory release = 100

0 23:33:06.088 test (EURUSD,D1) 3. Check indicator buffer:

0 23:33:06.088 test (EURUSD,D1) Size before memory free = 1054

0 23:33:06.088 test (EURUSD,D1) This is dynamic array = None

0 23:33:06.088 test (EURUSD,D1) Size after memory release = 0


Terminal MT5, no thoughts.

 
x572intraday #:

I wanted to circumvent the necessity to manually resize dynamic array simply by assigning it as an indicator buffer. But I can't get rid of ArrayResize() as if it were a dynamic array of indicator buffer whose size should be monitored by the terminal itself and which should not be resized manually:

https://www.mql5.com/ru/docs/series/bufferdirection:

We go to https://www.mql5.com/ru/docs/array/arrayisdynamic, run the code and suddenly find out that:

At the same time it:

I look in the book - I see a fig. Or have we been deceived all this time?

Or maybe it's dynamic once (at first initialization) and then that's it?

The buffer array is dynamic. In MQL, dynamic arrays have signs of objects, as far as I understood while working with them (as in ultra-high level languages). But if you declare a dynamic array as a buffer (using SetIndexBuffer), this area of memory will become reserved. That's why most standard functions can't change its size. I sometimes use object arrays as indicator buffers. And if I do, memory of such arrays is freed in object's destructor. Thus, the release of indicator buffer memory by the application(or object) itself is allowed. But it doesn't mean that the array can be freed right during the operation of the indicator. Everything should be done wisely.

 

Afternoon

Can you advise me, I'm trying to write an Expert Advisor, and when I test it a strange thing happens...

I have a function

CalcAngleTrend(NormalizeDouble((a[0]-a[1]), MA_DIGITS));

double CalcAngleTrend(double d)
 {
  double a = (double) ((atan(d*pow(10,_Digits-2)))*(180/M_PI)*coefAngle);
Print("d: ", d);
  return(NormalizeDouble(a, ANGLE_DIGITS));
 }

What's the situation, I start one instance of the EA running on a chart, and run the second one in the debug mode on the same chart with MT4
The input data for the function is the same, but the output data is different!!!? I just don't understand something, it seems...(

Это выдает запущеный вариант:

2022.01.25 15:01:12.880 USDJPY,M5: d: 0.0014887
2022.01.25 15:01:12.880 USDJPY,M5: d: -0.0060861
2022.01.25 15:01:12.880 USDJPY,M5: Angle Slow: +1.70580000
2022.01.25 15:01:12.880 USDJPY,M5: Angle Fast: -6.96560000

это в режиме отладки:

2022.01.25 15:01:14.330 USDJPY,M5: d: 0.0014887
2022.01.25 15:01:14.330 USDJPY,M5: d: -0.0060861
2022.01.25 15:01:14.330 USDJPY,M5: Angle Slow: +4.26450000
2022.01.25 15:01:14.330 USDJPY,M5: Angle Fast: -17.41390000

advise me which way to dig for information!!!

PS: calculated the difference of exactly 2.5 times the output
 
Владимир Казаков write an Expert Advisor, and when I test it a strange thing happens...

I have a function

What's the situation, I start one instance of the EA running on a chart, and run the second one in the debug mode on the same chart with MT4
The input data for the function is the same, but the output data is different!!!? I just don't understand something, it seems...(

can you tell me which way to dig for information?!

PS: calculated the difference of exactly 2.5 times the output

It's all about the formula for calculating the angle. In the code can be seen that for its calculation used only one coordinate and some coefficient, whose purpose is unclear. What is this? Please elaborate on what data you are using to calculate the angle.

 
Is it possible to have several watch lists (market overviews) in Metatrader? For example, one for indices, another for stocks
 
Vladimir Makhnin #:
Is it possible to have several watch lists (market overviews) in Metatrader? For example: indexes in one, stocks in another

Make your own. MQL5 makes this easy.

 
Mihail Matkovskij #:

It's all about the formula for calculating the angle. The code shows that only one coordinate is used to calculate it and some coefficient, the purpose of which is unclear. What is that? Please elaborate on what data you are using to calculate the angle.

As far as I can see

double d

it's a vector. But still it is only one coordinate. But to calculate an angle, you need two coordinates or a vector consisting of two coordinates.

 

both on the... my reply was deleted