why this simple code can not Correct modyfy my ticket

 
code for belw, can't modefy all ticdet's ordertakeprofit
   
void zhiying()
   {
       if(OrdersTotal()>0)
         {
            for(int dl=0;dl<OrdersTotal();dl++)
               {
                  if(OrderSelect(dl,SELECT_BY_POS,MODE_TRADES)==true)
                     {
                        int temp1024=StrToInteger(OrderComment());
                        if(getsuocangzhi(temp1024)==0)
                           {
                              if(OrderMagicNumber()==0)
                                 {
                                    if(OrderType()==OP_BUY)
                                       {//Alert(OrderTicket());
                                          if(OrderTakeProfit()==0)
                                             {
                                                if(OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble((OrderOpenPrice()+ying*Point),Digits),0,Yellow)==true)
                                                   {
                                                      Alert(OrderComment()+"号仓非锁仓分值单止盈价格修改成功");
                                                   }
                                                 else
                                                   {
                                                      Print(OrderComment()+"号仓非锁仓分值单止盈价格修改成功,请注意查错");
                                                   }   
                                             }
                                       }
                                    if(OrderType()==OP_SELL)
                                       {
                                          if(OrderTakeProfit()==0)
                                             {
                                                if(OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble((OrderOpenPrice()-ying*Point),Digits),0,Yellow)==true)
                                                   {
                                                      Alert(OrderComment()+"号仓非锁仓分值单止盈价格修改成功");
                                                   }
                                                 else
                                                   {
                                                      Print(OrderComment()+"号仓非锁仓分值单止盈价格修改成功,请注意查错");
                                                   }  
                                             }
                                       }   
                                 }
                           }
                     
                     
                     }
               }
         }
   }

the code can't modify all tidket's ordertakeprofit,can modyfy one
 
Print the Error when the OrderModify fails . . .
 
                        int temp1024=StrToInteger(OrderComment());
                        if(getsuocangzhi(temp1024)==0)

OrderComment() can be changed by your broker

That makes it possible that you not get the integer you want ...

 

my broker change my ordercommend()? why

how can solove the problem

 
  1. Brokers can change comments, including complete replacement.
  2. Always count down
  3. How should we know, you don't say what your storing there or why. https://www.mql5.com/en/forum/134204
 

From other topic zdj229 create

zdj229 2012.09.25 14:01
int getchicangshu(int chidan)
   {
       int chicangshu=0;
       
       if(OrdersTotal()>0)             
           {
             for(int tt1=0;tt1<OrdersTotal();tt1++)
               {
                 if(OrderSelect(tt1,SELECT_BY_POS,MODE_TRADES)==true)
                   {
                      if((OrderType()==OP_BUY)||(OrderType()==OP_SELL))
                         {
                           int temp8512=StrToInteger(OrderComment());
                           if(chidan!=temp8512) continue;
                                chicangshu=1;
                                break;

                         }
                   }
               }
             return(chicangshu);
           }
   }

i use the Function count the Current positions,but output is incorrect why

i have the ticket,but the script output 0,why


 
zdj229:

my broker change my ordercommend()? why

how can solove the problem

OrderMagicNumber()

Why don't you use it ??

Reason: