Download MetaTrader 5

OrderModify() - need some help please

To add comments, please log in or register
Format text in the messages editor. It is convenient!
FXBulldog
50
FXBulldog 2015.03.27 09:30 

I am trying to modify an order that is current/open.  To keep the changes that I want to make very simple at this stage (I am just trying to get the code right) all that i am attempting to do is find the order and then change the arrow colour to blue, but I get an OrderModify error code 4109.

 

Anyone spot where I am making the error in the code? 

FXBulldog
50
FXBulldog 2015.03.27 09:31  
 int    i,Pos,Error;
   int    Total=OrdersTotal();
   
   if(Total>0)
   {for(i=Total-1; i>=0; i--) 
     {if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == TRUE && OrderMagicNumber()==39379)
       { 
       bool res=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit(),0,Blue);}
            if(!res)
               Print("Error in OrderModify. Error code=",GetLastError());
            else
               Print("Order modified successfully.");
cdp21
36
cdp21 2015.03.27 09:55  

Error 4109 = "Trade is not allowed in expert properties"

You need to enable checkbox "Allow live trading" in the expert properties. 

FXBulldog
50
FXBulldog 2015.03.27 11:17  
Yes, but Live trading is active.  But perhaps this means the trade does not work on a practice account...  Does the code look OK to you?
To add comments, please log in or register