Errors, bugs, questions - page 1126

 

I am writing a ToR for an MT4 EA with a priority on accelerated data processing.

Please advise whether the sequence of calculations or sampling (what is the correct name - representative?) is important for speeding up.

I am attaching two variants in the form of pictures showing block diagrams.

If you can, please write how the code should look if the selective execution of the blocks will be - a purely primitive layout, and will this give a significant speed increase!

Files:
Logic_V_01.png  26 kb
Logic_V_02.png  30 kb
 
void OnStart()
{
        uchar max=0;
        for(int t=0;t<LONG_MAX;t++)   {max++;}    //так получаем предупреждение expression is always true, цикл работает
        for(int t=0;t<LONG_MAX+1;t++) {max++;}    //так предупреждение есть, но цикл не работает
        for(int t=0;t<ULONG_MAX;t++)  {max++;}    //так нет предупреждения и цикл не пашет
        Print("Done!");
}
 

How is this closing of a position in the tester explained? Is it due to spread widening?

Screenshots from MetaTrader trading platform

EURUSD, M20, 2014.04.12

Alfa-Forex, MetaTrader 5, Real

temp_file_screenshot_63279.png

EURUSD, M20, 2014.04.12, Alfa-Forex, MetaTrader 5, Real


 
Crucian:

How is this closing of a position in the tester explained? Is it the widening of the spread?

[img]https://charts.mql5.com/4/434/eurusd-m20-alfa-foreks-temp-file-screenshot-63279-png.png[/img]

If the spread has widened (and judging by the screenshot - by 720 points! on five digits), then everything is correct.

The sell position has closed at the Ask price. This is if the stops were set.

By the way, your brokerAlfa-Forex hasjust gigantic spreads at the end of the week and at the beginning.

Probably they were recorded in the quote history and the tester simulated trading on them.

Stops for the weekend are dangerous - they won't save from the gap anyway, and spread widening can easily catch you.

 
Fleder:
for(int t=0;t<LONG_MAX+1;t++) {max++;}    //так предупреждение есть, но цикл не работает

No error here becauseLONG_MAX+1< 0

for(int t=0;t<LONG_MAX;t++)   {max++;}    //так получаем предупреждение expression is always true, цикл работает
Here the warning is valid (t<LONG_MAX always true if t int ) infinite loop
 
void OnStart()
{
  uchar max=0;
  for(int t=0;t<ULONG_MAX-1 e0;t++)  {max++;}      //так цикл работает, предупреждения нет так как ULONG_MAX-1e0 имеет тип double
  for(int t=0;t<ULONG_MAX-1;t++)    {max++;}      //а так нет и предупреждения тоже нет
  Print("Done!");
}
 
Fleder:
for(int t=0;t<ULONG_MAX-1;t++)    {max++;}      //а так нет и предупреждения тоже нет
There is no error here, because ULONG_MAX-1< 0, i.e. the comparison operation is converted to int or long - more precisely there is a bitwise comparison
 
A100:
There is no error because ULONG_MAX-1< 0, because the comparison operation is reduced to int

Then how to explain this:

void OnStart()
{
  long t=0;
  bool comp=(ULONG_MAX-1>t);
  Print("comp = ",comp);   //comp = true
  Print(ULONG_MAX-1);      //18446744073709551614
  Print(ULONG_MAX);        //18446744073709551615
}
 
A100:
There is no error here because ULONG_MAX-1< 0, i.e. the comparison operation is cast to int or long

Do you mean the comparison in the tested expression in the loop?

Because it doesn't seem that way in a simple comparison.

 
A100:

Just swap them around :)

What does this rearrangement do? t was lower than ULONG_MAX-1 and still is.

void OnStart()
{
  long t=0;
  Print( (t < ULONG_MAX-1) == (ULONG_MAX-1 < t)); //false
}