Bug in OrderModify when used for Trailing Stops in EA

 
This is a serious problem. I sat down and noted this so I am sure it is a problem.

When the ordermodify is called to change the orderstoploss value, the stoploss value first assumes the orderentry price and then tries to change. However, this is a big problem because the logic used is as follows:
if(OrderStopLoss()>(Ask+Point*Trailing)) Ordermodify....

However, as the Stoploss value is now at orderentry price, it is definitely higher than the the ask+point*trailing. Thus, the trailingstop is allowed to move down. This is unacceptable. Please provide a fix immediately.

thanks.
 
In order to prove my point above, I did a trick. I modified my trailing stop code as follows:
      if(OrderType()==OP_SELL)
      {
       if(Trailing>0)  
       {                 
        if((OrderOpenPrice()-Ask)>(Point*profit))
        {
         if(((OrderStopLoss()>(Ask+Point*Trailing)) || (OrderStopLoss()==0)) && (OrderStopLoss()!=OrderOpenPrice()))
         {
          err = OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*Trailing,OrderTakeProfit(),0,Green);
          if (err < 0)
          {
           Print("OrderModify Buy failed. Err#:", GetLastError());
           return(0);
          }
          return ;
         }
        }
       }
       break;
      }
 



By using the command OrderStopLoss()!=OrderOpenPrice()), I was able to freeze the changed values of the Stoploss values to the Orderentry price, even when the reverted back for a moment to that value. Now, I was able to take a screen shot of the situation to offer as proof. See attached picture where you can see the SL = entry price.

[img]
http://www.strategybuilderfx.com/forums/attachment.php?attachmentid=19032&stc=1

[/img]

 
The correct code that I am using is as follows:

void TrailingAlls(int start,int stop)
{
 int profit=start;
 double stoptrade;
 double stopcal;
 double Trailing = stop;
 int err;
 
 if(stop==0)
  return;
 
 int trade;
 for(trade=OrdersTotal()-1;trade>=0;trade--)
 {
  if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
   continue;

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

      if(OrderType()==OP_BUY)
      {
       if(Trailing>0)  
       {                 
        if(Bid-OrderOpenPrice()>Point*profit)
        {
         if((OrderStopLoss()<Bid-Point*Trailing) || (OrderStopLoss()==0))
         {
          err = OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*Trailing,OrderTakeProfit(),0,Green);
          if (err < 0)
          {
           Print("OrderModify Buy failed. Err#:", GetLastError());
           return(0);
          }
          return ;
         }
        }
       }
       break;
      }
      if(OrderType()==OP_SELL)
      {
       if(Trailing>0)  
       {                 
        if((OrderOpenPrice()-Ask)>(Point*profit))
        {
         if((OrderStopLoss()>(Ask+Point*Trailing)) || (OrderStopLoss()==0))
         {
          err = OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*Trailing,OrderTakeProfit(),0,Green);
          if (err < 0)
          {
           Print("OrderModify Buy failed. Err#:", GetLastError());
           return(0);
          }
          return ;
         }
        }
       }
       break;
      }

 }//for
}



Two more pictures to prove my point. I am requesting Metatrader to correct this problem.

http://www.strategybuilderfx.com/forums/attachment.php?attachmentid=19034&stc=1
http://www.strategybuilderfx.com/forums/attachment.php?attachmentid=19035&stc=1

Check out the values of USDCHFm in both the cases. See what I am saying?

Maji

 
Now check out the image in the following link

http://www.strategybuilderfx.com/forums/attachment.php?attachmentid=19036&stc=1

Can you see that the USDCHF SL value has gone down? It should not because this is long trade and should move up only.

The logic is
if((OrderStopLoss()<Bid-Point*Trailing) || (OrderStopLoss()==0))
so, the previous OrderStopLoss Value must have been changed from the higher value as it now assumes a lower value. This is a BUG, unless I am making a BIG mistake. If it is a bug we need an immediate workaround or bug fix. This can cost us money!!!!

Thanks.
 
Slawa and other Metaquotes personnel...

Please acknowledge my message and let me know what your thoughts are.

Thanks.
 
Could you please send client terminal log-file of USDCHF order?
 
Could you please send client terminal log-file of USDCHF order?


I have emailed you the log file. Please let me know when you have the bug fixed.
 
Thank you.
...
00:00:04 RubberBand AUDJPYm,M1: modify #3202722 buy 0.10 NZDUSDm at 0.6157 sl: 0.6298 tp: 0.0000 ok
...
00:00:14 RubberBand AUDJPYm,M1: modify #3202722 buy 0.10 NZDUSDm at 0.6157 sl: 0.6157 tp: 0.0000 ok
...
00:00:24 RubberBand EURJPYm,M1: modify #3202722 buy 0.10 NZDUSDm at 0.6157 sl: 0.6297 tp: 0.0000 ok


Conclusion:
Your the same expert advisors running on AUDJPYm,M1 and EURJPYm,M1 are 2 different expert advisors!
Your several expert advisors move your S/L!
You should define more differentiation for Magic Numbers. Your magic numbers should be different on different symbols!
Reason: