Error 1 on order modify.

 

I am getting error 1 a good percentage of the time when modifying the stop loss on existing orders. When looking at the openprice, current stoploss and the proposed stoploss it looks ok.

For example, on a EURUSDm short trade (after checking the conditons are valid) I use ASK + 0.0025 for the new stoploss so thought the distance from the BID price would be sufficient in most cases.

My question are;

1. My EA display says its ok but it fails - could this be due to the rounding of the 5th decomal place. In other words is the 5th decimal place significant when setting the stoploss. requiring normalise double all the time?

If so should MT4 be changed to do this automatically??

2. I have checked the spread with Error 1 and its ok at about 185 but the stop and freeze levels are both 05. Assume this is 0.00005, but how do i use these figures. I know they can prevent a trade modification, but how can i determine if the trade will be accepted or rejected - how exactly do I use these levels

 

Did you look at what error 1 means ?

"OrderModify attempts to replace the values already set with the same values. One or more values must be changed, then modification attempt can be repeated."

 
Here. sxTed code gives a good list of things to check for to avoid Error#1. We cannot say whats wrong with your code because we cannot see it.
 
if(Use_Fixed_TS==true)
  {
     if(Trailing_Stop(Fixed_Trail_Stop)==1) Comment("Trail Stop ok");
     else   
       {
        Comment("Error in Trailing Stop");
        //-------------------------------------------------------------------------------- 7 --
        // Error handling section
        //--------------------------------------------------------------------------------------
         int Error=GetLastError();                           // Failed :(
         switch(Error)                                       // Overcomable errors
            {
               case 130:Alert("Wrong stops. Retrying.");
                  RefreshRates();                         // Update data
                  break;                                  // At the next iteration
               case 136:Alert("No prices. Waiting for a new tick..");
                  while(RefreshRates()==false)            // To the new tick
                     Sleep(1);                            // Cycle delay
                  break;                                  // At the next iteration
               case 146:Alert("Trading subsystem is busy. Retrying ");
                  Sleep(500);                             // Simple solution
                  RefreshRates();                         // Update data
                  break;                                  // At the next iteration
                                                          // Critical errors
               case 2 : Alert("Common error.");
                  break;                                   // Exit 'switch'
               case 5 : Alert("Old version of the client terminal.");
                  break;                                   // Exit 'switch'
               case 64: Alert("Account is blocked.");
                  break;                                   // Exit 'switch'
               case 133:Alert("Trading is prohibited");
                  break;                                   // Exit 'switch'
               default: Alert("Occurred error ",Error);    //Other errors
             }
        }                                                  // End of If Ans==false           
   }                                                       // End of Trail Stop section
return(0);                                                 // End of start function
}
 
//---------------------------------------------------------------------------------  
//  function Trailing Stop
//---------------------------------------------------------------------------------

bool Trailing_Stop(int Stop)
{
 bool Answer=false;
 string Text;                               
 int Tipo=OrderType();                                            // Order type
 int i;
 for(i=0; i<=OrdersTotal(); i++)                                  // Cycle searching in orders
    {
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)           // Select if the next is available
        {                                                         // Analysis of orders:
         if(OrderSymbol()!=Symbol()||Tipo>1)continue;             // The order is not "ours" continue with next OrderSelect
         double SL=OrderStopLoss();                               // SL of the selected order
         while(true)                                              // Modification cycle
           {
            double TS=Stop*pips2dbl;                                 // Trail Stop x 10 because I use a 5 digit broker
            double Min_Dist=MarketInfo(Symbol(),MODE_STOPLEVEL);  // Min. distance
            Comment(MarketInfo(Symbol(),MODE_STOPLEVEL));          // 
            if(TS<Min_Dist) TS=Min_Dist;                          // If less than allowed New value of TS 
            bool Modify=false;                                    // start with a Not to be modified instruction
            switch(Tipo)                                          // Evaluate By order type
              {
               case 0 :                                           // Case Buy Order
               SL=NormalizeDouble(Bid-TS,Digits);           // calculate new SL
               if(OrderStopLoss()<SL)                             // If Order Stop Loss is lower than what we want
                 {
                   Text=" Buy ";                                  // Text for Buy 
                   Modify=true;                                   // To be modified
                 }
               break;                                             // Exit 'switch'
               case 1 :                                           // Case Sell Order
                   SL=NormalizeDouble(Ask+TS,Digits);       // calculate new SL
                   if(OrderStopLoss()>SL)                         // If Order Stop Loss is higher than what we want
                     {
                      Text=" Sell ";                              // Text for Sell 
                      Modify=true;                                // To be modified
                     }
              }                                                   // End of 'switch'
            if(Modify==false)break;                               // If it is not modified exit while            
            Alert("Modification to",Text,"#",OrderTicket()," - Awaiting response..");
            Answer=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0);    //Modify it!
            if(Answer==true)                                      // Got it! :)
              {
               Alert("Order ",Text,OrderTicket()," is modified:)");
               break;                                             // From modification cycle.
              }
            }                                                     // End of modification cycle while (true)
          continue;                                               // continue with next OrderSelect
         }                                                        // End of select operator
     }                                                            // End of order search
  return(Answer);
 }
  
  
  
//+-------------------------  the end  ------------------------------------------------+