Errors, bugs, questions - page 2662

 

I have a tough case - there is no logic available to me.

There is a function with these inputs

int Tree_Calcf(int &arr_List_Buy[],int &arr_List_Sell[],int Vektor_ZZ,int Variant_Tree_Buy=0,int Variant_Tree_Sell=0)
{
int CalcBuy=1;
int CalcSell=1;
//Print("Rez_Tree_Calc=",Rez," - f"," Vektor_ZZ=",Vektor_ZZ," CalcSell=",CalcSell);

if (Vektor_ZZ==1)
{
if(Variant_Tree_Buy==1)
{
                        if(arr_List_Buy[272]< 0.5 && arr_List_Buy[100]< 0.5 && arr_List_Buy[249]< 0.5 && arr_List_Buy[147]< 0.5 && arr_List_Buy[350]< 0.5 && arr_List_Buy[383]< 0.5 && arr_List_Buy[463]< 0.5 && arr_List_Buy[250]< 0.5 && arr_List_Buy[283]< 0.5 && arr_List_Buy[204]< 0.5 && arr_List_Buy[499]< 0.5 && arr_List_Buy[296]< 0.5 && arr_List_Buy[486]< 0.5 && arr_List_Buy[209]< 0.5 && arr_List_Buy[453]< 0.5 && arr_List_Buy[333]< 0.5 && arr_List_Buy[137]< 0.5 && arr_List_Buy[127]< 0.5 && arr_List_Buy[191]< 0.5 && arr_List_Buy[395]< 0.5 && arr_List_Buy[224]< 0.5 && arr_List_Buy[432]< 0.5 && arr_List_Buy[378]< 0.5 && arr_List_Buy[25]< 0.5 && arr_List_Buy[441]< 0.5 && arr_List_Buy[2]< 0.5 && arr_List_Buy[465]< 0.5 && arr_List_Buy[231]< 0.5 && arr_List_Buy[482]< 0.5 && arr_List_Buy[324]< 0.5) CalcBuy=0; //(0.83965634 0.16034366)
//--Вырезана часть аналогичного кода - листья дерева
}

//V03
if(Variant_Tree_Buy==2)
{
//---Вырезан код, он не активируется в момент ошибки}
//--Дерево на базе активации листьев без фильтров
if(Variant_Tree_Buy==3)
{
//---Вырезан код, он не активируется в момент ошибки}
}
//----TreeList_Sell
if(Vektor_ZZ==-1)
{
if(Variant_Tree_Sell==1)
{

                        if(arr_List_Sell[127]< 0.5 && arr_List_Sell[275]< 0.5 && arr_List_Sell[42]< 0.5 && arr_List_Sell[389]< 0.5 && arr_List_Sell[121]< 0.5 && arr_List_Sell[410]< 0.5 && arr_List_Sell[39]< 0.5 && arr_List_Sell[348]< 0.5 && arr_List_Sell[358]< 0.5 && arr_List_Sell[143]< 0.5 && arr_List_Sell[396]< 0.5 && arr_List_Sell[364]< 0.5 && arr_List_Sell[354]< 0.5 && arr_List_Sell[160]< 0.5 && arr_List_Sell[324]< 0.5 && arr_List_Sell[46]< 0.5 && arr_List_Sell[38]< 0.5 && arr_List_Sell[397]< 0.5 && arr_List_Sell[295]< 0.5 && arr_List_Sell[48]< 0.5 && arr_List_Sell[322]< 0.5 && arr_List_Sell[363]< 0.5 && arr_List_Sell[40]< 0.5 && arr_List_Sell[420]< 0.5 && arr_List_Sell[43]< 0.5 && arr_List_Sell[230]< 0.5 && arr_List_Sell[10]< 0.5 && arr_List_Sell[471]< 0.5 && arr_List_Sell[507]< 0.5 && arr_List_Sell[259]< 0.5) CalcSell=0; //(0.78952321 0.21047679)





//--Вырезана часть аналогичного кода - листья дерева
} if(Variant_Tree_Sell==2) { //---Вырезан код, он не активируется в момент ошибки } //--Дерево на базе активации листьев без фильтров if(Variant_Tree_Sell==3) { //---Вырезан код, он не активируется в момент ошибки } } int Rez=0; if(Vektor_ZZ==1)Rez=CalcBuy; if(Vektor_ZZ==-1)Rez=CalcSell; Print("Rez_Tree_Calc=",Rez," - f"," Vektor_ZZ=",Vektor_ZZ," CalcSell=",CalcSell); return Rez; }

So, this Function sometimes outputs a value of 769

2020.03.01 15:54:23.500 Core 1  2019.11.13 22:57:00   Rez_Tree_Calc=769 - f Vektor_ZZ=-1 CalcSell=769

If you uncomment the first print

//Print("Rez_Tree_Calc=",Rez," - f"," Vektor_ZZ=",Vektor_ZZ," CalcSell=",CalcSell);

then it gives the correct value.

If you truncate the function by removing just the code which is not activated at the moment the function is called at the moment of error, there is no error as well.

Obviously a compiler error - developers, who to send the full function to, because it does not fit on the forum.

 
The forum distorts the formatting of the code, it is not possible to correct.
 
It turns out that adding parentheses has a miraculous effect in solving the problems described above:

class A{};

template<typename T>
class B{
public:
   B(int &){}
   B(long){}
   B(int, int, int){};  
   B(const B&){}
   B(const A*){}
};

// template class type
B<A*> test_b_class_class(){
   B<A*> b(1);
   int x = 22;
   
   return ( B<A*>(1));             // Fixed Compile Error: ambiguous call to overloaded function with the same parameters: "B(long)" and "B(const A*)"
   return ( B<A*>(1,2,3));         // Fixed Compile Error: only one argument is acceptable, argument should be castable to int
   return ( B<A*>(x));             // Fixed Compile Error: argument is passed by value instead of by reference.
   return ( B<A*>((A*)NULL));      // Fixed Compile Error: 'int' - invalid cast operation        
   return ( B<B<B<long>>>(1));     // Fixed Compile Error: OK, template parameter type does not provide any effort on compilation result
   
   return b;
};

B<A*>* test_b_ptr_ptr(){
   B<A*> b(1);
   
   return &( B<A*>(1));            // Fixed Compile Error: '&' - illegal operation use
   return &b;                 
};


void OnStart (){    
   // template class type
   B<A*> b0 = test_b_class_class();
   B<A*>* b_ptr = test_b_ptr_ptr();
}
 
Sergey Dzyublik:
It turns out that adding parentheses has a miraculous effect in solving the problems described above:

That's the only way I write.

 
MT5 bug (build 2345) compilation error for the return value of a template function when the return value is an internal class located inside a template class whose parameter type is given by the argument type of the template function:

template<typename T>
class A{
public:
   class B{
   public:
      B(){};
      B(B&){};
   };
   
   A(){};
   A(A&){}
};

class C{
public:
   class D{
   public:
      D(){}
      D(D&){}
   };
};


template<typename T>
A<int>::B* test_b_ptr(const T n){             //OK
   A<T>::B* ptr = new A<int>::B();
   return ptr;
}

template<typename T>
A<int>::B test_b_in_place_class(const T n){   //OK
   return (A<T>::B());
}

template<typename T>
A<int>::B* test_b_in_place_ptr(const T n){    //OK
   return &(A<T>::B());
}


template<typename T>
A<T> test_a_template(const T n){              //OK
   A<T> a;
   return a;
}

template<typename T>
C::D test_d(const T n){                       //OK
   C::D d;
   return d;
}

template<typename T>
A<T>::B test_b_template(const T n){          //'A' - unexpected token, probably type is missing? 
   A<T>::B b;
   return b;
}



void OnStart (){ 
   test_b_ptr(1);
   test_b_in_place_class(1);
   test_b_in_place_ptr(1);
   
   
   test_a_template(1);
   test_d(1);
   test_b_template(1);                       // Compile Error
}
 
// "MetaTrader 5\MQL5\Files\Reports\2020.03.01 03.43.46ExpertName (琼㹤⸱㠰㐹㰷琯㹤琼㹤⼼摴㰾摴ㄾ〮ㄹ㔷⼼摴㰾摴㈾㄰⸹㠰ㄮ‴㈰〺㨰〰ㄮ㐱⼼摴㰾摴ㄾ〮〹㐵⼼摴㰾摴㰾琯㹤琼㹤⼼摴㰾摴㰾琯㹤琼㹤㰰琯㹤琼㹤⼼摴㰾摴㰾琯㹤琼㹤⼼摴㰾摴 - )\"

Please copy this text (taken from the Terminal log) into ME, move the cursor to the end of the line and try deleting characters via the BackSpace key. I have a reproducible bug.

On the animation note the position of the cursor. I press BackSpace and it deletes characters that are far away from the cursor.


ZZY Everything is fine in Notepad, not in ME.

Search string: Uluchshenie 012.
 
fxsaber:

Please copy this text (taken from the Terminal log) into ME, move the cursor to the end of the line and try deleting characters via the BackSpace key. I have a reproducible bug.


ZY everything is fine in Notepad, not in ME.

In ME Win10-64 no problem deleted

I think I copied everything, I have the last characters:

摴 - )\"

ZY: there's a trick in ME, I have a .mql4/mql5 source files of 50 KB, on the forums the same code will take 5-6 KB, I think the trick is in the encoding Unicode-"not Unicode" - I do not remember already, where someone discussed


UPD: ME menu: file - save as - at the bottom of the encoding, I default to Unicode

 
Igor Makanu:

UPD: ME menu : file - save as - bottom encoding , my default is Unicode

Same at the bottom.

Forum on trading, automated trading systems and strategy testing

Bugs, bugs, questions

fxsaber, 2020.03.01 16:10

I'm trying to open an animation and pay attention to the cursor position. I press BackSpace and delete characters that are far from the cursor.

 
fxsaber:

Please copy this text (taken from the Terminal log) into ME, move the cursor to the end of the line and try deleting characters via the BackSpace key. I have a reproducible bug.

In the animation, note the position of the cursor. I press BackSpace and it deletes characters that are far away from the cursor.


ZY In Notepad it's fine, in ME it's not.

Search string: Uluchshenie 012.

I had the same bug recently. Only I also lost the cursor. I restarted ME, it didn't happen again. Thought there was something wrong with the Windows.
 
Vladislav Andruschenko:
Restarted ME, never happened again.

Restarting does not help.

Reason: