Errors, bugs, questions - page 2691

 
Igor Makanu:

Why? Mostly simple types can be converted to bytes this way:

this code (first part) should work in C# as well, at least I never had any problems with integer types, it seems like variant #3 already

you can wrap my code in a loop to make it a bit more compact

UPD:

I can use union as well.

void OnStart()
  {
   uchar a[];
   UByte<int> b=0xA2F38114;
   if (b.GetArray(a))
      for (int i=0;i<sizeof(int);PrintFormat("%#x",a[i++]));
   }

template<typename T>
union UByte{
   T  val;
   uchar arr[sizeof(T)];
   T operator =(T x) {return val=x;}
   bool GetArray(uchar &mArr[]) {return ArrayCopy(mArr,arr)==sizeof(T);}
};
 
Vladimir Simakov:

It is also possible to use union right away.

This was once the result.

#include <TypeToBytes.mqh> // https://www.mql5.com/ru/code/16280

void f( const uchar &Array[] )
{
  ArrayPrint(Array);
  
  Print("----");
}

void OnStart()
{
  int i = 5;
  double d[] = {0, 1, 2};

  // Простые типы и их массивы
  f(_R(i).Bytes);
  f(_R(d).Bytes);
  
  MqlTick Tick = {0};
  MqlTick Ticks[2];

  // Простые структуры и их массивы.
  f(_R(Tick).Bytes);
  f(_R(Ticks).Bytes);
  
  string Str;
  string StrArray[] = {"12", "34", "56"};
    
  // Строки и их массивы.
  f(_R(Str).Bytes);
  f(_R(StrArray).Bytes);
}

I.e. complete uniformity. And other goodies.

 
Vladimir Simakov:

You can also use union right away.

There was an example of this above, and it's quite a chorus)))

 

Hi all, the question is as follows.

Why is it that when the indicator buffers are numbered correctly, their names are displayed incorrectly:

I change the numbering to (what seems to me) incorrect and the buffer names are displayed correctly:

The indicator is rendered correctly in both.

P.S. If I make buffer #0 and its COLOR INDEX #1 numbers 2 and 3 respectively, with a corresponding change in all numbering, the histogram (which is buffer #0) is drawn over the lines in the indicator. And I don't need this.

 

You don't get an SMS when you sign up for a demo account, so if you've already done it that way, make it work consistently. If you have already done it in this way, then make it work consistently.

 
 

Why does the terminal connect to the server with a higher ping when it has a lower one?

How do I fight it?

build 2363

 
Andrey Dik:

Why does the terminal connect to the server with a higher ping when it has a lower one?

How do I fight it?

build 2363

Maybe because the connection is better?


 
Artyom Trishkin:

Maybe because the connection is better?


the first server has better connection (according to the indicator), but the terminal always connects to the 3rd one, I manually reconnect to the 1st one.

I admit that i sometimes loose connection with 1st server and terminal connects to the first available one, but if i can reconnect to 1st one manually, why terminal can't do it itself?

and the third server is so slow that the quotes in the market overview stop for a few minutes!

 
Andrey Dik:

The first server has a better connection (according to the indicator), but the terminal always connects to the 3rd one, I reconnect manually to the 1st one.


Then I don't know...

Reason: