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

 
This is a huge revelation to me
// Скрипт показыает, что цены открытия/закрытия не просто не нормализованы, но и разные при схожем значении

#property strict

#include <MT4Orders.mqh>

// Заполнение массива ценами открытия/закрытия
int FillPrices( double &Prices[] )
{
  const int Total = OrdersHistoryTotal();
  
  ArrayResize(Prices, Total << 1);
  
  int Amount = 0;
  
  for (int i = 0; i < Total; i++)
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
    {
      Prices[Amount++] = OrderOpenPrice();
      Prices[Amount++] = OrderClosePrice();
    }

  return(ArrayResize(Prices, Amount));
}

// true - нормализованная разность равна нуля, сама разность - отлична от нуля.
bool IsBadPrices( const double &Price1, const double &Price2 )
{
  return(!NormalizeDouble(Price1 - Price2, 5) && (Price1 != Price2));
}

// Находит цены открытия/закрытия, которые
// с нормализацией равны друг другу,
// без нормализации - не равны.
int CheckPrices( const double &Prices[] )
{
  int Res = 0;
  const int Size = ArraySize(Prices);
  
  for (int i = 0; i < Size - 1; i++)
  {
    const double Price = Prices[i];
    
    for (int j = i + 1; j < Size; j++)
      if (IsBadPrices(Price, Prices[j]))
      {
        Print((string)Price + " - " + (string)Prices[j] + " = " + (string)(Price - Prices[j])); // Распечатываем найденые цены
        
        Res++;
      }
  }
    
  return(Res);
}

void OnStart()
{
  double Prices[];
  
  FillPrices(Prices);
  Print(CheckPrices(Prices)); // Количество "несовпадающих" пар цен.
}


Result

1.95562 - 1.95562 = -2.220446049250313 e-016
1.95562 - 1.95562 = -2.220446049250313 e-016
1.71599 - 1.71599 = -2.220446049250313 e-016
1.71599 - 1.71599 = -2.220446049250313 e-016
1.58028 - 1.58028 = -2.220446049250313 e-016
14.806 - 14.806 = -1.77635683940025 e-015
1.95521 - 1.95521 = -2.220446049250313 e-016
1.95521 - 1.95521 = -2.220446049250313 e-016
8


Running the same script on MT4 is even more depressing - there is a bigger story there. Let me explain.


Here you see that the position was opened and closed at the same price. But their prices are not equal when comparing without normalization!


ZZY Checked Tester - no such nastiness there, it seems.

 
Ilya Malev:

I must have made a typo.

So the minimum spread is real there? If so, you should write to tech support to get it corrected (to medium). Otherwise it's a tidbit for tester grails.

 
fxsaber:

Checked the Tester - there doesn't seem to be any such nastiness.

In all Tester modes, except real ticks, prices are not normalised!

// Советник выводит цены, которые не нормализованы

#property strict

// true - нормализованная цена не равна оригинальной
bool IsBadPrice( const double &Price )
{
  return(NormalizeDouble(Price, 5) != Price);
}

#define  TOSTRING(A) #A + " = " + (string)(A) + " "

//const bool Init = EventSetMillisecondTimer(50);
//void OnTimer()
void OnTick()
{
  for (int i = SymbolsTotal(true) - 1; i >= 0; i--)
  {
    const string Symb = SymbolName(i, true);
    
    const double PriceBid = SymbolInfoDouble(Symb, SYMBOL_BID);
    const double PriceAsk = SymbolInfoDouble(Symb, SYMBOL_ASK);
    
    if (IsBadPrice(PriceBid))
      Print(TOSTRING(Symb) + TOSTRING(PriceBid) + TOSTRING(NormalizeDouble(PriceBid, 5) - PriceBid));

    if (IsBadPrice(PriceAsk))
      Print(TOSTRING(Symb) + TOSTRING(PriceAsk) + TOSTRING(NormalizeDouble(PriceAsk, 5) - PriceAsk));
  }
}


Result

2019.02.18 23:57:24   Symb = EURUSD PriceBid = 1.13088 NormalizeDouble(PriceBid,5)-PriceBid = -2.220446049250313 e-016 
2019.02.18 23:57:26   Symb = EURUSD PriceAsk = 1.13112 NormalizeDouble(PriceAsk,5)-PriceAsk = -2.220446049250313 e-016 
2019.02.18 23:57:27   Symb = EURUSD PriceBid = 1.13085 NormalizeDouble(PriceBid,5)-PriceBid = -2.220446049250313 e-016 
2019.02.18 23:58:18   Symb = EURUSD PriceAsk = 1.13112 NormalizeDouble(PriceAsk,5)-PriceAsk = -2.220446049250313 e-016 


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

 

Let's say you cannot connect to the trading server when you try to log in to your account.

Or, for example, your demo account has expired and you are trying to log in with "Invalid account".


Despite this failure all trading history is available, even if it is not shown in the Terminal!

 
fxsaber:

Let's say you cannot connect to the trading server when you try to log in to your account.

Or, for example, your demo account has expired and the login attempt gives "Invalid account".


Despite this failure all trading history is available, even if it is not shown in the Terminal!

So where is the history stored?

 
Alexey Navoykov:

I.e. is the minimum spread realistic there? If so, you should write to tech support to get it fixed (to medium). Otherwise it's a tidbit for tester grails.

In the branch "bugs, questions" have already replied officially that nothing will not change. More precisely, they simply ignored all rational questions and answered "test by real ticks", which I interpret as a strictly negative answer

It's a "tidbit" for unfortunate self-deception. Although, maybe someone else can use it commercially to cheat in some way (namely, the brokerage companies - which thus create a false impression of the spreads norm, if the person does not get into real ticks, and 99.9% will not do so)
 
Ilya Malev:

Although it may be that someone else can use it commercially to cheat somehow (namely, brokerage companies - which thus create a false impression of the spreads norm, if the person does not get into real ticks, and 99.9% will not).

In theory, everything should be synchronized on the server. What is in ticks - should be in bars. But of course, I do not know how it is in reality.

 
Comments not relevant to this topic have been moved to "Features of mql4 language, intricacies and techniques".
 

ME has an ALT+V combination where you can see the previous values of the system clipboard. Even if you copied something from the browser and ME was working in the background, ME will see it and remember it.

Roughly speaking, ME sees a lot of what you do on the computer. For example, if you paste in a password for an account or personal account from another resource via the buffer, it will go into the history of the current ME session.

 
fxsaber:

ME has an ALT+V combination where you can see the previous values of the system clipboard. Even if you copied something from the browser and ME was working in the background, ME will see it and remember it.

Roughly speaking, ME sees a lot of what you do on the computer. For example, if you paste in an account password via the buffer, it will go into the history of the current ME session.

Wow, I copy cryptocurrency passwords. How detrimental is that to me?

Reason: