Features of the mql5 language, subtleties and tricks - page 115

 
A100:

I won't write what I can, in case it turns out to be simple and pavlick_ again

I don't understand your behaviour.

 
Comments not related to this topic have been moved to "Questions from MQL5 MT5 MetaTrader 5 beginners".
 
Alexey Navoykov:
Casting a pointer won't do anything. No matter how you cast it, the object is the same.

I stand corrected.

 

Who tried to test on real ticks, is it necessary to create a 1-minute history or it will be formed on the basis of uploaded ticks(custom symbol)?

I somehow don't have a test, I've uploaded seven days of ticks, I'm running the test and this is what's in the logs:

2018.12.24 22:04:16.925 Core 1  no data synchronized, 41 bytes read
2018.12.24 22:04:16.925 Core 1  symbol EURUSD_custom synchronization error
2018.12.24 22:04:16.925 Core 1  cannot get history EURUSD_custom,M1
 
forexman77:

Who tried to test on real ticks, is it necessary to create a 1-minute history or it will be formed on the basis of uploaded ticks (custom symbol)?

I'm somehow not going to test, uploaded seven days of ticks, running the test is what's in the logs:

So far.

 

DoubleToString for "same" price calculations can give different results. In this case DoubleToString may be different from NormalizeDouble.

#property strict

#define  PRINT(A) Print(#A + " = " + (string)(A))

void OnStart()
{
  const double Koef =  0.25;
  const int iDelta = 32;
  const double point = 0.00001;
  
  const double high = 1.06736;
  const double low = 1.06676;
  
  const double Avg = (high + low) * 0.5;  
  const double Size = (high - low) * Koef * 0.5;
  
  // Вычисление одной и той же цены разной последовательностью сложения одного и того же количества пипсов
  const double Price1 = Avg - Size - point * iDelta;
  const double Price2 = Avg - (Size + point * iDelta);  
  
  PRINT(DoubleToString(Price1, 5));   // DoubleToString(Price1,5) = 1.06666
  PRINT(DoubleToString(Price2, 5));   // DoubleToString(Price2,5) = 1.06667

  PRINT(NormalizeDouble(Price1, 5)); // NormalizeDouble(Price1,5) = 1.06667
  PRINT(NormalizeDouble(Price2, 5)); // NormalizeDouble(Price1,5) = 1.06667
}
 
fxsaber:

DoubleToString for "same" price calculations can give different results. In this case DoubleToString may be different from NormalizeDouble.

The described behavior is not an exclusive feature of the MQL5 language."The way real numbers are represented in machine memory is defined by IEEE Standard 754 and is independent of platforms, operating systems and programming languages. "
 

If anyone needs a template unresolved static variable based on https://www.mql5.com/ru/forum/1111/page2364#comment_10048274

The problem is solved by implementing the method at the declaration place. It's not very nice, but it works.

Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2018.12.28
  • www.mql5.com
Общее обсуждение: Ошибки, баги, вопросы
 
Ilya Malev:

If anyone needs a template unresolved static variable based on https://www.mql5.com/ru/forum/1111/page2364#comment_10048274

The problem is solved by implementing the method at the declaration place. It is not very nice, but it works.

You have an extra word static there. It is not used outside a class

 
Alexey Navoykov:

You have an extra word static listed there. It is not used outside the class.

(tired) if it were the problem, the "'k' - redefinition; different type modifiers" error would have appeared, but it is not on the screenshot. So the compiler doesn't care and that's not it.


Reason: