Errors, bugs, questions - page 3018

 
Artyom Trishkin:

Then you will have to draw to the indicator line + candlesticks for the indicator that should be drawn below the candlesticks. For the others - which are drawn above the candlesticks, set the chart to draw the candlesticks in the background. I personally do not see any other way.

But, in terms of convenience and flexibility of building programs in MQL5, you can ask MQL5 developers to create a property for the indicator buffer (for any of the indicator buffers).

 

in build 2940 they rewrote Alglib, now working with complex numbers is a structure (there was a class)

and made mistakes:

#include <Math\Alglib\complex.mqh>
void OnStart()
{
      al_complex a(1, 2);
      al_complex b(3, 4);
      a += b;
      printf("tst#1 : a.real = %f , a.imag = %f", a.re, a.im);

      al_complex c(1, 2);
      al_complex d(3, 4);
      c -= d;
      printf("tst#2 : c.real = %f , c.imag = %f", c.re, c.im);
 }

2021.05.23 21:49:35.210 tst (EURUSD,H1) tst#1 : a.real = 4.000000 , a.imag = 6.000000

2021.05.23 21:49:35.210 tst (EURUSD,H1) tst#2 : c.real = 4.000000 , c.imag = 6.000000


source complex .mqh

//+------------------------------------------------------------------+
//| Overloading (+=)                                                 |
//+------------------------------------------------------------------+
void al_complex::operator+=(const al_complex &rhs)
  {
   re+=rhs.re;
   im+=rhs.im;
  }
//+------------------------------------------------------------------+
//| Overloading (-=)                                                 |
//+------------------------------------------------------------------+
void al_complex::operator-=(const al_complex &rhs)
  {
   re+=rhs.re;
   im+=rhs.im;
  }
 

I don't remember that a new data type complex was announced , but without plugin libraries everything works correctly:

void OnStart()
{
      complex a(1, 2);
      complex b(3, 4);
      a += b;
      printf("tst#1 : a.real = %f , a.imag = %f", a.real, a.imag);

      complex c(1, 2);
      complex d(3, 4);
      c -= d;
      printf("tst#2 : c.real = %f , c.imag = %f", c.real, c.imag);
 }

2021.05.23 21:54:13.976 tst (EURUSD,H1) tst#1 : a.real = 4.000000 , a.imag = 6.000000

2021.05.23 21:54:13.976 tst (EURUSD,H1) tst#2 : c.real = -2.000000 , c.imag = -2.000000




where did the new complex type come from ? .... there is nothing in the help, and what else was added?

 
Igor Makanu:

I don't remember that a new data type complex was announced , but without plugin libraries everything works correctly:

2021.05.23 21:54:13.976 tst (EURUSD,H1) tst#1 : a.real = 4.000000 , a.imag = 6.000000

2021.05.23 21:54:13.976 tst (EURUSD,H1) tst#2 : c.real = -2.000000 , c.imag = -2.000000




where did the new complex type come from ? .... there is nothing in the help, and what else was added?

There was a confirmation from the developers that new types were added. Recently.

 
Igor Makanu:

I don't remember that a new data type complex was announced , but without plugin libraries everything works correctly:

2021.05.23 21:54:13.976 tst (EURUSD,H1) tst#1 : a.real = 4.000000 , a.imag = 6.000000

2021.05.23 21:54:13.976 tst (EURUSD,H1) tst#2 : c.real = -2.000000 , c.imag = -2.000000

where did the new complex type come from ? .... there is nothing in the help, and what else was added ?

Here:

7. MQL5: Added support for operations with complex numbers.


Added new built-in type "complex".
struct complex
  {
   double             real;   // вещественная часть
   double             imag;   // мнимая часть
  };
The "complex" type can be passed by value as a parameter for MQL5-functions (as opposed to usual structures, which are passed only by reference). For functions that are imported from DLL, the "complex" type must be passed by reference only.

To describe complex constants the suffix 'i' is used:
.
complex square(complex c)
  {
   return(c*c);
  }
  
void OnStart()
  {
   Print(square(1+2 i));  // в качестве параметра передается константа
  }

// будет выведено "(-3,4)" - это строковое представление комплексного числа
For complex numbers only simple operations are available: =, +, -, *, /, +=, -=, *=, /=, ==, !=.

Additional mathematical functions will be added in the future: getting absolute value, sine, cosine and many others.
Новая версия платформы MetaTrader 5 build 2940: Перенос витрин MQL5-сервисов в рабочую область и обновление дизайна
Новая версия платформы MetaTrader 5 build 2940: Перенос витрин MQL5-сервисов в рабочую область и обновление дизайна
  • 2021.05.14
  • www.mql5.com
В пятницу 21 мая 2021 года будет выпущена обновленная версия платформы MetaTrader 5...
 
Artyom Trishkin:

Here:

7. MQL5: Added support for working with complex numbers.


Added a new built-in type "complex".
The complex type can be passed by value as a parameter for MQL5 functions (in contrast to the usual structures, which are passed only by reference). For functions that are imported from DLL, the "complex" type must be passed only by reference.

To describe complex constants the suffix 'i' is used:
For complex numbers only simple operations are currently available: =, +, -, *, /, +=, -=, *=, /=, ==, !=.

Additional mathematical functions will be added in the future: getting absolute value, sine, cosine and many others.

OK thanks, it's a pity that the help is added late

 
Execution error:
void OnStart()
{
    const string text[] = { "ABC", "", "ABC" };
    uchar array[];
    int start = 0;
    int n = 0;
    for ( int i = 0; i < ArraySize( text ); i++ )
    {
        const int count = StringLen( text[ i ] );
        n += StringToCharArray( text[ i ], array, start, count );
        start += count;
    }
    Print( ArraySize( array ), ":", n );
}

Result: 6:7

Expected: 6:6

 
A100:
Execution error:

Result: 6:7

Expected: 6:6

count = 0 - only the end of the string is copied. Yet "" != NULL.

 
fxsaber:

count = 0 - only the end of the string is copied. Still "" != NULL.

And how many

StringToCharArray

should it copy at count = 0 ?

Hint: 3 characters are copied when count = 3

 
A100:

should copy the characters when count = 0 ?

it looks like count=0 works the same way as count=-1 and in the case of "" it copies a terminal null, so without additional checks an empty string cannot be converted normally