ERROR 129

 

I've read some other posts and just no idea how to resolve this problem. I am still using a demo account (on Alpari - may not be as reliable as LIVE account).

I have an array MOT with details of all current orders. The following is from my own log. The 204762 is a reference to the write_to_log location (in the code) which checks the error code and provides other printed information.

I have just added Refreshrates(). (the ticket is the ticket # I want to close - i.e. it is valid)

My_Slippage = 40;

================LOG====================

Location 204762 Unanticipated error: 129 invalid price
204762 2011.08.11 15:08:54 Sell MoH - Close B_or_S = Sell NCHC = 1 ticket_nos = 223261677


            {  ticket_nos     = MOT[i1][4];
               Lots           = MOT[i1][5]; 
               Order_Profit   = MOT[i1][8];
               RefreshRates();
               OrderClose(ticket_nos,Lots,Bid,My_Slippage,Bisque); 
               if ( My_Test_Flag == "YES" ) write_to_log(204762,"YES");
               Sleep(My_Sleep);
            }
 

The order you are trying to close is a Buy order ? I assume it is as you are trying to close at the Bid price ?

Add a Print statement before the OrderClose and print all the relevant info, e.g. . . .

Print("ticket = ",ticket_nos, " Lots= ",Lots. " Bid= ", Bid, " Slip= ", My_Slippage);

OrderClose(ticket_nos,Lots,Bid,My_Slippage,Bisque); 
 
  1.             {  ticket_nos     = MOT[i1][4];
                   Lots           = MOT[i1][5]; 
                   Order_Profit   = MOT[i1][8];
    Fraught with typo danger and confusion. Document your code.
    #define TICKET 4
    #define LOTS   5
    #define PROFIT 8
    #define MOTSIZE 9 // Largest index + 1
    double MOT[...][MOTSIZE];
    ...
                {  ticket_nos     = MOT[i1][TICKET];
                   Lots           = MOT[i1][LOTS]; 
                   Order_Profit   = MOT[i1][PROFIT];
    Also, Mql4 allows MOT[i1, TICKET] which might be easier for some
  2. 04762 2011.08.11 15:08:54 Sell MoH - Close B_or_S = Sell NCHC = 1 ticket_nos = 223261677
    Your message says it is a sell order but your closing via Bid. Buy open at Ask close at Bid. Sell open at Bid, close as the Ask

  3. // OrderClose(ticket_nos,Lots,Bid,My_Slippage,Bisque); 
    if (!OrderSelect(ticket_nos,SELECT_BY_TICKET))
        Print( "OrderSelect(",oo.ticket,",Ticket) failed: ",
                                            GetLastError() );
    else if (!OrderClose(ticket_nos,Lots,OrderClosePrice(),My_Slippage,Bisque))
        Alert("OrderClose failed: ",GetLastError());
    If you use OCP() you don't care whither it's Bid or Ask. ALWAYS test return codes. I don't know where you get the 129 error message based on what you posted.
 
WHRoeder:
  1. Fraught with typo danger and confusion. Document your code. Also, Mql4 allows MOT[i1, TICKET] which might be easier for some
  2. 04762 2011.08.11 15:08:54 Sell MoH - Close B_or_S = Sell NCHC = 1 ticket_nos = 223261677
    Your message says it is a sell order but your closing via Bid. Buy open at Ask close at Bid. Sell open at Bid, close as the Ask

  3. If you use OCP() you don't care whither it's Bid or Ask. ALWAYS test return codes. I don't know where you get the 129 error message based on what you posted.

thanks for help. I think I made a mistake. Your suggestion for OCP seems to make sense.

The error 129 comes as a result of the write_to Log routine. The use of "YES" checks the error code see code

void write_to_log(int location,string check4error)
{  
   string WTL=location+" "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)+" "+B_or_S;   // WTL - Write To Log
   int i1;
   if ( check4error  == "YES" )
   {  error = GetLastError();
      if ( error > 0 )
      {  FileWrite(My_Handle,"Location "+location+" Unanticipated error: "+error+" "+ErrorDescription(error));
         error = 0;              //maybe return (0); here
      }
   }
   switch (location)
   {  case 10000: WTL=WTL+" MC - Enters Manage Contracts"; break;

etc
 
peterhw1:
The error 129 comes as a result of the write_to Log routine. The use of "YES" checks the error code see code

That's where the 129 is printed not where is comes from (code you DIDN'T post.)

Always test return codes [int ticket=OrderSend(); if (ticket < 0) Alert(GetLastError());] and capture the error number immediately before it is overridden.

 
WHRoeder:

That's where the 129 is printed not where is comes from (code you DIDN'T post.)

Always test return codes [int ticket=OrderSend(); if (ticket < 0) Alert(GetLastError());] and capture the error number immediately before it is overridden.

Many thanks.

In practice I thought I was testing the error code after use - but also adding a time & date stamp plus where (in the code) the error had originated. The write_to_log occurs immediately after the OrderClose() statement

Reason: