Errors, bugs, questions - page 1642

 
When trying to create an object of an abstract class, the log shows too scanty information about the error: 'CClass - cannot instantiate abstract class. And I would like to know which methods are missing, because there are so many abstract methods, and it takes a long time to find the missing one. Please make sure that the first missing method is indicated in the log.
 
Alexey Valeev:

After today's update on 18.08.2016 the OrderCalcMargin function started returning 0.

Terminal version Demo 5.00 build 1383

Test code:

Output in terminal:

2016.08.18 20:35:36.394 Test (EURUSD,H1) OneLot=0.0 GetLastError=0

ps: also wrote to servicedesk, but there's a suitable thread here too, so maybe this message will be responded to quicker.

Fixed it. Thank you for the message.
 

No check on pure virtual method implementation

class A {
        virtual void f() = 0;
};
void A::f() {} //нормально
 
fxsaber:
Debug error (build 1383)
Thought it was fixed. But no, it's 1395.
 

Maybe it's not a serious bug, but it's always bugging me.

the essence of the graphical object such as OBJ_RECTANGLE_LABEL disappears a couple or one pixel, it seems nothing, but it's not good ...

it disappears at the top left when the object is in dark colours....

 
Compilation error
template<typename T>
void f( T t1, T t2 = 0 ) {} //error: '0' - illegal operation use
Otherwise, it's fine.
template<typename T>
class A {
void f( T t1, T t2 = 0 ) {} //нормально
};
 

In MQL5\Include\environment.mqh there is such a double comparison

//+------------------------------------------------------------------+
//| Сравнивает два значения типа double.                             |
//| RESULT                                                           |
//|   Возвращает истину, если значения равны и                       |
//|   ложь в противном случе.                                        |
//+------------------------------------------------------------------+
bool CEnvironment::DoubleEquals(const double a,const double b)
  {
//---
   return(fabs(a-b)<=16*DBL_EPSILON*fmax(fabs(a),fabs(b)));
//---
  }

In Help, there is a variant from MQL4\Libraries\stdlib.mq4

//+------------------------------------------------------------------+
//| right comparison of 2 doubles                                    |
//+------------------------------------------------------------------+
bool CompareDoubles(double number1,double number2)
  {
   if(NormalizeDouble(number1-number2,8)==0) return(true);
   else return(false);
  }
 
fxsaber:

In MQL5\Include\environment.mqh there is such a double comparison

In Help, there is a variant of MQL4\Libraries\stdlib.mq4

double Look. And we read it. And we see two ways of comparison:

  • The first way consists in comparing the difference between two numbers with some small value, which defines the precision of comparison.
    Example:
    bool EqualDoubles(double d1,double d2,double epsilon) 
      { 
       if(epsilon<0) epsilon=-epsilon; 
    //--- 
       if(d1-d2>epsilon) return false; 
       if(d1-d2<-epsilon) return false; 
    //--- 
       return true; 
      } 
    void OnStart() 
      { 
       double d_val=0.7; 
       float  f_val=0.7; 
       if(EqualDoubles(d_val,f_val,0.000000000000001)) Print(d_val,"equals",f_val); 
       else Print("Different: d_val = ",DoubleToString(d_val,16), 
                  "  f_val = ",DoubleToString(f_val,16)); 
    // Результат: Different: d_val= 0.7000000000000000   f_val= 0.6999999880790710 
      }

  • The second method involves comparing the normalized difference between two real numbers with a value of zero. Comparing the difference of the normalised numbers to zero is useless because any mathematical operation with normalised numbers results in an un-normalised result.
    Example:

    bool CompareDoubles(double number1,double number2) 
      { 
       if(NormalizeDouble(number1-number2,8)==0) return(true); 
       else return(false); 
      } 
    void OnStart() 
      { 
       double d_val=0.3; 
       float  f_val=0.3; 
       if(CompareDoubles(d_val,f_val)) Print(d_val,"equals",f_val); 
       else Print("Different: d_val = ",DoubleToString(d_val,16), 
                  "  f_val = ",DoubleToString(f_val,16)); 
    // Результат: Different: d_val= 0.3000000000000000   f_val= 0.3000000119209290 
      }

 
Karputov Vladimir:

The second way involves comparing the normalized difference of two real numbers to zero. It is useless to compare the difference of normalised numbers to zero, because any mathematical operation with normalised numbers results in an un-normalised result.

This is not true. The difference of two normalized doubles will always be zero if their normalized values are the same. I don't need to cite an example when comparing float and double. This is not the case of two double's.

Moreover you can take two numbers whose normalized values are equal to each other. But their normalized difference will not equal zero.

 

Compile error: ')' - not all control paths return a value

int f()
{
        while ( true ) //или for(;;)
        {
//много строк c return, continue, без break
                return 0;
//много строк c return, continue, без break
                return 1;
        }
}
Reason: