Features of the mql4 language, subtleties and techniques - page 17

 

Forum on trading, automated trading systems and trading strategies testing

Features of mql5 language, tips and tricks

fxsaber, 2019.02.20 07:26

Prices are not normalised in all Tester modes!

To put it mildly, this is a bug in the Tester.


Whether this also applies to Birt-mode, I don't know.

 

Apologies if this is off-topic (can't say I follow language development), could you explain exactly what this line does?

#property strict

Let me explain.

There's a script that compares two (identical in MT) prices.

#property strict

void OnStart()
{
   const int Total = OrdersHistoryTotal();
   int Prices1, Prices2;
   
   double open_price, close_price;
   OrderSelect("37027330", SELECT_BY_TICKET, MODE_HISTORY);
   open_price = OrderOpenPrice();
   close_price = OrderClosePrice();

   Print(open_price);
   Print(close_price);
   Print(open_price-close_price);
   
   return;
}

In MT the prices are equal, but the difference is not equal to zero (as written above).

If this line(#property strict) is removed, the difference is zero.

Why?

 
Dmitry Rannev :

Apologies if this is off-topic (can't say I follow language development), could you explain exactly what this line does?

Let me explain.

There's a script that compares two (identical in MT) prices.

In MT the prices are equal, but the difference is not equal to zero (as written above).

If this line ( #property strict) is removed, the difference is zero.

Why?

"#property strict" is only useful with mql4. With mql5 it is useless, as "strict" mode is always true.
 
Alain Verleyen:
"#property strict" is only useful with mql4. With mql5 it is useless because "strict" is always true.

This is the MT4 we are talking about. There has been a discussion above about the normalisation problem. We are trying to understand why some prices in MT4 are equal and when compared are not. This is a continuation of.

 
Dmitry Rannev:

That's what MT4 is all about. There has been a discussion above about the normalisation problem. We are trying to understand why some prices in MT4 are equal and when compared are not. This is a continuation.

Dimitri, this topic is worn to the ground. Forgive me if I reveal a secret, but you have people like Kirill aka Programmer, Sergei ... I won't say the last name, "it's too famous to give it away" © They know it all...

 
Dmitry Rannev:

Apologies if this is off-topic (can't say I follow language development), could you explain exactly what this line does?

Let me explain.

There's a script that compares two (identical in MT) prices.

In MT the prices are equal, but the difference is not equal to zero (as written above).

If this line(#property strict) is removed, the difference is zero.

Why?

void OnStart()
{
  double Price1 = DBL_EPSILON;
  double Price2 = 0;

  Print(Price1 - Price2);          // 0 - грубо показывает.
  Print((Price1 - Price2) * 1 e15); // не ноль
}


The strict has no effect on the equality. Only on Print - either roughly or more accurately shows the number.

 
Dmitry Rannev:

In MT the prices are equal, but the difference is not zero (as written above).

If this line(#property strict) is removed, then the difference is zero.

Numbers of double type cannot be checked for equality (including zero), we need to compare their difference to the minimum value(DBL_EPSILON, FLT_EPSILON, Point)

 
Ilya Malev:

Numbers of type double cannot be checked for equality (including zero), you must compare their difference to the minimum value(DBL_EPSILON, FLT_EPSILON, Point)

That's not what we're talking about.

 
fxsaber:

It's about something else.

I tried to imagine what caused the question and came to the conclusion that there might have been some errors in the algorithm, not just a question about Print.

 
Ilya Malev:

I tried to imagine what caused the issue and came to the conclusion that there might have been some errors in the algorithm and not just a question about Print.

The problem was described by fxsaber above. We are trying to find the cause.