Errors, bugs, questions - page 3005

 
What happened to the "All messages" link in the profile?
 
fxsaber:
Where did the link to "All messages" in the profile go?
.
 
Alexey Viktorov:

Thank you!

 

Forum on trading, automated trading systems and trading strategy testing

Not normalized prices in MT4

fxsaber, 2021.04.30 10:42

Two different numbers converted to string the same way. Is it a bug?

void OnStart()
{
  const double Num = 1.07299;
  const double Norm = NormalizeDouble(Num, 5);
   
  Print(Num);  // 1.07299
  Print(Norm); // 1.07299

  Print(Num - Norm); // 2.220446049250313e-16
}

The situation is similar to this one.

 

Custom indicator in subwindow, oscillator type.
How to hide the default zero line ?
Coloring the zero line from the GUI, to match the background colour does not work.

i

setting properties in the indicator, does not work

#property indicator_level1  0.0
#property indicator_levelcolor C'35,35,35'
 
fxsaber:

The numbers are different, but the difference is 17 decimal places, and Print handles only 15 decimal places, so from Print's point of view they are the same

 
A100:

The numbers are different, but the difference is the 17th decimal place, while Print handles only 15 digits, so from the Print point of view they are the same.

Only not Print, but conversion of double to string.

 

Figure 1

Noticed this. If the forward test data are repeated (the same), when viewing the Backtest for all three variants, only variant (10384.88) will be shown first.

Fig2

The data for variants with results = 10435 or 10843 are unknown (everything in the reports for variant = 10384)??


 

Can you tell me how to copy data from pointers correctly?

You need to copy data from one object to another. Then delete the initial object. When you delete the original object, the data in the copy object becomes inaccessible.

#include <Arrays\ArrayObj.mqh>

CArrayObj ArrCur;       // массив с объектами, каждый объект содержит структуру с полями ордеров и его id
CArrayObj ArrPrev;  // массив с объектами, каждый объект содержит структуру с полями ордеров и его id

class CID : public CObject
{
  public:  int id;
};


void OnStart()
{
  // -----------------------------------------------------------------
    CID* pCur = new CID;        // создаем объект для текущих параметров
    pCur.id = 25;               // вносим текущие данные
    ArrCur.Add(pCur);           // помещаем в массив объектов
    
    CID* pPrev = ArrCur.At(0);  // копируем данные??? Указатель???
    ArrPrev.Add(pPrev);         // помещаем в массив объектов
    
    ArrCur.Clear();             // чистим текущий массив
  // -----------------------------------------------------------------
  
   // --- для вывода в журнал
  int sizeCur = ArrCur.Total();       // размер = 0
  int sizePrev = ArrPrev.Total();     // размер = 1
  
  ENUM_POINTER_TYPE pTypeCur = CheckPointer(ArrCur.At(0));    // POINTER_INVALID
  ENUM_POINTER_TYPE pTypePrev = CheckPointer(ArrPrev.At(0));  // POINTER_INVALID
  
  Print(__FUNCTION__, " sizeCur=", sizeCur, " pTypeCur=", EnumToString(pTypeCur));
  Print(__FUNCTION__, " sizePrev=", sizePrev, " pTypePrev=", EnumToString(pTypePrev));

}
 
There the pointer copies