Errors, bugs, questions - page 2264

 

Please help, I still can't figure out the reasons.


This code compiles for some unknown reason

class A {};

class B : public A
{
public:
  void f()
  {
    Print(__FUNCTION__);
  }
};

void OnStart()
{
  A a;
  
  ((B*)(&a)).f(); // OK
}

but it crashes at runtime. I thought it was a compilation bug - no big deal.


But then I wrote the code like this

#property script_show_inputs

input string FileName = "Alpari_GBPAUD.ZIP";

#include <Zip\Zip.mqh> // https://www.mql5.com/ru/articles/1971

void OnStart()
{
  CZip Zip;

  Zip.LoadZipFromFile(FileName, 0);

  uchar Bytes[];

  ((CZipFile*)Zip.ElementAt(0)).GetUnpackFile(Bytes);
  Print("UnZip - unpack size " + (string)ArraySize(Bytes) + " bytes.");  
}


Not only it compiles, but it is executed successfully too! I must be badly dumb somewhere, but I failed to understand why it works without any problems.

Unfortunately, I didn't manage to localize it, so the example with a ZIP-bibble. And, most likely, it would be a bummer to figure it out. But it doesn't matter.

 

Terminal (1881) crashes on debug if variable is in binary format

Play the animation to see

This probably only applies to union variables

 
Nikolai Semko:

Terminal (1881) crashes on debug if variable is in binary format

Play the animation to see

This probably only applies to union variables

Thanks for the message.

Fixed it.
The fix will be included in the next build.

 
fxsaber:

Please help, I still can't figure out the reasons.


This code compiles for some unknown reason

but it crashes at runtime. I thought - well, it's a compilation bug - no big deal.

...

You are trying to cast a pointer to an object of type A to a pointer to an object of type B, which is an obvious error, because A is not inherited from B
 
Ilyas:
You are trying to cast a pointer to an object of type A to a pointer to an object of type B, which is an obvious error since A is not inherited from B

This I understand. But it's not at all clear why the same action in the ZIP-bibble example works. It's exactly the same ghost there.

ZS I figured it out.

 

The backlight goes out... then reappears


Files:
Error1.mqh  1 kb
 

I have faced such a problem when testingresults on four and five digits (especially on small MT4) in MT4. The results are significantly different (5 and 4 digits recognition is implemented in the Expert Advisor) at least the number of deals increases significantly. Who knows or has suggested the reason? Perhaps it does not depend on the sign, but on the type of order execution - normal and market?

P.S. In both cases the quotes were loaded through Tisckstory.


Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
  • www.metatrader5.com
Тестер стратегий позволяет тестировать и оптимизировать торговые стратегии (советники) перед началом использования их в реальной торговле. При тестировании советника происходит его однократная прогонка с начальными параметрами на исторических данных. При оптимизации торговая стратегия прогоняется несколько раз с различным набором параметров...
 
Good afternoon. Can you tell me if it is possible to change the indicator display settings from the Expert Advisor code? For example, the colour or thickness of lines. Thank you in advance.
 
SuhanovDM94:
Hi, I would like to share my thoughts on this topic with you. Do you know if you can change the indicator display settings from within the Expert Advisor code? For example, the colour or thickness of lines. Thank you in advance.

You can, but

  1. Only at the moment of indicator creation
  2. Only if the indicator colour and line settings are included in the input parameters (an example of such an indicator isCustom Moving Average Inputs)

 
SuhanovDM94:
Hello. Do you know if you can change the settings of an indicator display from within the code of an Expert Advisor? For example, the colour or thickness of lines. I would like to thank you in advance.

Why would you want to change the colour and thickness of the EA? It doesn't affect its performance in any way. Do you need it for a picture? So change it in a template in the settings of the indicator.

Reason: