错误、漏洞、问题 - 页 2662

 

我有一个棘手的案子--没有任何逻辑可供我使用。

有一个函数,有这些输入

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; }

因此,这个函数有时会输出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

如果你取消对第一个打印的注释

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

那么它就会给出正确的值。

如果你把函数截断,只删除出错时调用函数 时没有激活的代码,也不会有错误。

显然是一个编译器错误 - 开发人员,把完整的功能发给谁,因为它不适合在论坛上。

 
该论坛扭曲了代码的格式,不可能纠正。
 
事实证明,添加括号对解决上述问题 有神奇的效果。

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:
事实证明,添加括号对解决上述问题 有神奇的效果。

这是我唯一的写作方式。

 
MT5错误(build 2345)当模板函数的返回值是一个位于模板类内部的内部类,其参数类型由模板函数的参数类型给出时,模板函数的返回值会出现编译错误

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 (琼㹤⸱㠰㐹㰷琯㹤琼㹤⼼摴㰾摴ㄾ〮ㄹ㔷⼼摴㰾摴㈾㄰⸹㠰ㄮ‴㈰〺㨰〰ㄮ㐱⼼摴㰾摴ㄾ〮〹㐵⼼摴㰾摴㰾琯㹤琼㹤⼼摴㰾摴㰾琯㹤琼㹤㰰琯㹤琼㹤⼼摴㰾摴㰾琯㹤琼㹤⼼摴㰾摴 - )\"

请将这段文字(取自终端日志)复制到ME中,将光标移到行末,并尝试通过BackSpace键删除字符。我有一个可重复的错误。

在动画中注意光标的位置。我按下BackSpace,它删除了离光标很远的字符。


ZZY 在记事本中一切正常,在ME中则不正常。

搜索字符串:Uluchshenie 012。
 
fxsaber:

请将这段文字(取自终端日志)复制到ME中,将光标移到行末,并尝试通过BackSpace键删除字符。我有一个可重复的错误。


ZY在记事本中一切正常,在ME中不正常。

在ME Win10-64中,没有问题被删除

我想我复制了所有的东西,我有最后的字符。

摴 - )\"

ZY:在ME中有一个技巧,我有一个50KB的.mql4/mql5源文件,在论坛上同样的代码需要5-6KB,我想这个技巧是在编码Unicode-"非Unicode"-我不记得了,在那里有人讨论过


UPD: ME菜单:文件-另存为-在编码的底部,我默认为Unicode

 
Igor Makanu:

UPD: ME菜单:文件-另存为-底部编码,我的默认是Unicode。

底部也一样。

关于交易、自动交易系统和策略测试的论坛

虫子,虫子,问题

fxsaber, 2020.03.01 16:10

我试图打开一个动画并注意光标的位置。我按下BackSpace,删除离光标较远的字符。

 
fxsaber:

请将这段文字(取自终端日志)复制到ME中,将光标移到行末,并尝试通过BackSpace键删除字符。我有一个可重复的错误。

在动画中,注意光标的位置。我按下BackSpace,它删除了离光标很远的字符。


ZY在记事本中很好,在ME中则不然。

搜索字符串:Uluchshenie 012。

我最近也有这样的毛病。只是我也失去了光标。我重新启动了ME,它没有再发生。还以为Windows出了什么问题。
 
Vladislav Andruschenko:
重新启动了ME,再也没有发生。

重新启动并没有帮助。