Download MetaTrader 5

No error returned, but the result is unknown

To add comments, please log in or register
GrumpyDuckMan
338
GrumpyDuckMan  

Hello everyone,

I need some help to understand what this runtime error means. I have been trying to work it out, but I am making myself very confused about where the problem starts.

   CurrAsk= MarketInfo(Curr,MODE_ASK);
   CurrBid= MarketInfo(Curr,MODE_BID);
   Ticket=60055216;
   Price=0.800133;
 
     bool ModifyOrder=OrderModify(Ticket,Price,CurrBid*2,TAKE_PROFIT,0,clrNONE);  //No error returned, but the result is unknown
     if(!ModifyOrder)
 
      Alert("Error With Order Modify. =",GetLastError());
      else
 
      Print("Order modified successfully.");
      }
GrumpyDuckMan
338
GrumpyDuckMan  

log Report:

2       18:45:51.727    Main AUDUSD,H1: modify #60055216 sell 0.05 AUDUSD at 0.80133 sl: 1.60068 tp: 0.00000 ok
0       18:45:51.727    Main AUDUSD,H1: Order modified successfully.
0       18:45:51.727    Main AUDUSD,H1: Alert: Error With Order Modify. =1
0       18:45:52.819    Main AUDUSD,H1: uninit reason 4
0       18:45:53.131    Expert Main AUDUSD,H1: removed
Drazen Penic
2703
Drazen Penic  

Note

Open price and expiration time can be changed only for pending orders. If unchanged values are passed as the function parameters, the error 1 (ERR_NO_RESULT) will be generated.


  • Besides that, I don't see OrderSelect() in your code snippet. You have to select order before you can modify it.

OrderModify - Trade Functions - MQL4 Reference
OrderModify - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderModify - Trade Functions - MQL4 Reference
Keith Watford
Moderator
10645
Keith Watford  
Drazen Penic:

  • Besides that, I don't see OrderSelect() in your code snippet. You have to select order before you can modify it.

You do not need to select an order before modifying it. However if you are going to use OrderOpenPrice() etc in the modification, the order must be selected first.
Drazen Penic
2703
Drazen Penic  
Keith Watford:
You do not need to select an order before modifying it. However if you are going to use OrderOpenPrice() etc in the modification, the order must be selected first.

I didn't know that.

Every piece of code I wrote always searched for the order(s) by looking into their types, magic numbers, instrument so I always had to do OrderSelect() before modify. 

GrumpyDuckMan
338
GrumpyDuckMan  
Drazen Penic:


  • Besides that, I don't see OrderSelect() in your code snippet. You have to select order before you can modify it.

I have selected the order to Modify.


 Ticket=60055216;

My SL isn't set properly at the moment. it follows, but its at an incorrect value

Main AUDUSD,H1: modify #60055216 sell 0.05 AUDUSD at 0.80133 sl: 1.60068 tp: 0.00000 ok
Drazen Penic
2703
Drazen Penic  
GrumpyDuckMan:
I have selected the order to Modify.


My SL isn't set properly at the moment. it follows, but its at an incorrect value


The error indicates that you are trying to modify the transaction, but new values are the same as old ones.

Print actual values and new values before you call OrderModify() and check that you are actually changing something.

GrumpyDuckMan
338
GrumpyDuckMan  
Drazen Penic:

The error indicates that you are trying to modify the transaction, but new values are the same as old ones.

Print actual values and new values before you call OrderModify() and check that you are actually changing something.

Thank you, I'll have a look. Myself I believe its the way I coded SL in the order modify. SL is a long way above even parity.
GrumpyDuckMan
338
GrumpyDuckMan  

hello everyone,

I think that I might be a little bit closer to get this working.  Why does ModifyOrder equal false?

  int min_stop=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);
   CurrAsk= MarketInfo(Curr,MODE_ASK);
   CurrBid= MarketInfo(Curr,MODE_BID);
   Ticket=60162332;  // int
   Price=0.79633;    // double
   double Number= 0.00050;
   double NewStopLoss=Price+Number;
    
   bool ModifyOrder=OrderModify(Ticket,Price,NewStopLoss,TAKE_PROFIT,0,clrNONE);
        if(!ModifyOrder) Alert("Error With Order Modify. =",GetLastError());else Print("Order modified successfully.");
Keith Watford
Moderator
10645
Keith Watford  
GrumpyDuckMan:

hello everyone,

I think that I might be a little bit closer to get this working.  Why does ModifyOrder equal false?


Because the OrderModify() failed.

GrumpyDuckMan
338
GrumpyDuckMan  
{
   double  Number = 0.00050;   
   int     Ticket = 60287536; // sell
   double  Price  = 0.79259;  // sell
   
   int     Ticket1= 60287617; //buy
   double  Price1 = 0.79268;  //buy
 
   double BuyStopLoss=Price1-Number;
   double SellStopLoss=Price+Number;
      
   bool BuyModifyOrder=OrderModify(Ticket1,Price1,BuyStopLoss,TAKE_PROFIT,0,clrNONE);
        if(!BuyModifyOrder) Alert("Error With Order Modify. =",GetLastError());else Print("Order modified successfully.");
      

   bool SellModifyOrder=OrderModify(Ticket,Price,SellStopLoss,TAKE_PROFIT,0,clrNONE);
        if(!SellModifyOrder) Alert("Error With Order Modify. =",GetLastError());else Print("Order modified successfully.");
      } 

Hello,

I manage to get half the code to work now.  Now I have found that if BuyStopLoss ,or SellStopLoss value isn't to 5 decimal places it will be false.  I'm not sure I understand this problem atm. I have given Price and Price1 a value, but price1 most of the time is greater than 5 decimal place.

12
To add comments, please log in or register