分形的突破--图解 - 页 3

 

我切换了OrderModify和OrderSelect两个函数的参数,但没有用。

流程似乎是合乎逻辑的,我已经仔细检查了所有的参数。


这是在回测 中发生的,但不应该有问题。

 
//----------------------------------------------//
//-----------------EXITING ORDERS---------------//


for(int i=OrdersTotal()-1; i>=0;i--)
   {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;
    if(OrderMagicNumber()!=MagicNumber || OrderSymbol() !=Symbol()) continue;
    double SL=OrderStopLoss();
    bool   result;
    int    error;
    //Different OrderTypes
    if(OrderType()==OP_BUY)
       {
        if(BreakEven > 0) 
          {
           if(Bid - OrderOpenPrice() >= Point * BreakEven * mypoint)  //make input for BreakEven    StopLoss)
              {                                                                   //and don't forget mypoint !!!
               if(OrderStopLoss() < OrderOpenPrice()) 
                 {
                  SL = OrderOpenPrice()+Point;
                 }
              }
          }
       }
    if(OrderType()==OP_SELL)              
       {
         //For you to do
          
              
               
                
               
                  
                   
             
             
       }
    if(SL != OrderStopLoss()) result=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,CLR_NONE);
         if(result!=TRUE) { error=GetLastError(); Print("ModifyError = ",OrderTicket(),"   ",error);}       
   }

让编码更容易阅读

看看与你自己的写作有什么不同,这更容易计数 {{{{{{{{{{{{{{{ }}}}}}}}}}}}}}

 
ZacharyRC:

仍然有困难。我进行了错误查找,以找出原因。


日志已经报告了。

1)错误4051=参数不正确

2) 修改订单的票据无效

//----------------------------------------------//
//-----------------EXITING ORDERS---------------//


for(int i=OrdersTotal()-1; i>=0;i--)
   {
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;


   if(OrderMagicNumber()!=MagicNumber || OrderSymbol() !=Symbol()) continue;

   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) Print(GetLastError(),i);
   if(OrderType()==OP_BUY)
      {
      if(Move.BE && StopLoss > 0) 
         {
         if(Bid - OrderOpenPrice() >= Point * StopLoss)
            {
            if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) 
               {
               OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red);
               Print("Cant Modify Order"+GetLastError(),i);
               }
            } 
         }
      }
   else
      {
      if(Move.BE && StopLoss > 0) 
         {
         if(OrderOpenPrice() - Ask >= Point * StopLoss)
            {
            if(OrderStopLoss() > OrderOpenPrice() - Point * MoveStopTo)
               {
               OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() - Point * MoveStopTo, OrderTakeProfit(), 0, Red);
               Print("Cant Modify Order"+GetLastError(),i);
               }
            }
         }
      }
   }

对于买入,SL怎么可能高于开盘价? OrderOpenPrice() + Point * MoveStopTo

 
deVries:

对于 "买 "来说,在修改成功和交易获利后,有可能使OrderStopLoss()高于OrderOpenPrice()。
大笑.......哎呀<红脸笑脸>。
 
RaptorUK:
大笑.......哎呀<红脸笑脸>。


小心羞愧,删除我的帖子
 
ZacharyRC:

仍然有困难。我进行了错误查找,以找出原因。


期刊曾报道过。

1)错误4051=参数不正确

2) 修改订单的无效票据

好吧,也许你的错误信息是虚假的 . . .

 if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) Print(GetLastError(),i);


               OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() - Point * MoveStopTo, OrderTakeProfit(), 0, Red);
               Print("Cant Modify Order"+GetLastError(),i);

如果OrderSelect()有效,你为什么还要调用GetLastError()? 如果它确实向你显示了一个错误,那就不是由于OrderSelect()造成的。

OrderModify()的情况也一样,如果修改成功,你还在调用GetLastError(),为什么?只有在函数失败时才调用。

            if(OrderStopLoss() > OrderOpenPrice() - Point * MoveStopTo)
               {
               if(!OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() - Point * MoveStopTo, OrderTakeProfit(), 0, Red))
                  Print("Cant Modify Order, error# " + GetLastError()," index ", i);
 
deVries:

谨防羞辱,删除我的帖子
不,我是人,我也会犯错,我不介意人们知道这一点 :-)
 

AHHH我喜欢它。你的两个观点都很有道理。


{{{{}}}}}-也是很容易的!

只有当函数 失败时才应该调用错误。


谢谢你们两位,我希望你们的周末过得很愉快。

 
RaptorUK:

对于买入,SL怎么可能高于开盘价? OrderOpenPrice() + Point * MoveStopTo


SL是在订单下面。



你确定你指的不是卖出部分吗?

 else{
 
    if(Move.BE && StopLoss > 0) {
               if(OrderOpenPrice() - Ask >= Point * StopLoss)
                {
                  if(OrderStopLoss() > OrderOpenPrice() - Point * MoveStopTo)
                   {
                  OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() - Point * MoveStopTo, OrderTakeProfit(), 0, Red);
                  Print("Cant Modify Order"+GetLastError(),i);
}
 
RaptorUK:
大笑.......哎呀<红脸笑脸>。

这是我的一个错误。