- The price you passed to the function was not a current Bid price - 129
void CloseOrders(int index,double price,string fromwhere) { OrderClose(ticket_nos, Lots ,price,My_Slippage,Green); Sleep(My_Sleep); RefreshRates();
If the close fails, what good is the refreshRate. you are still using the original passed in price.{ OrderClose(ticket_nos, Lots ,price,My_Slippage,Green); int my_error = GetLastError();On a error the internal error variable gets set. GetLastError retrieves the value and reset it. If the OrderClose succeeds, GetLastError could be anything, like an error from ObjectCreate. Test your return codes{ if(OrderClose(ticket_nos, Lots ,price,My_Slippage,Green)) return(0); int my_error = GetLastError();- If you OrderSelect the ticket first, you need not pass anything OrderClose(OrderTicket(), OrderLots(), OrderClosePrice() ...
- PS used the SRC button - normally get the different colors in the code but not hereSometimes page gets messed up. Select all and copy, previous page and re-click, paste
WHRoeder:
- If you OrderSelect the ticket first, you need not pass anything OrderClose(OrderTicket(), OrderLots(), OrderClosePrice() ...
this seems a lot better. Got the message on the refreshrates (so obvious now)
thanks
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have been trying to close 2 similar orders one after the the other - one seems to succeed and the other (2nd) fail on more than one occasion.
Both orders would be either Buy or Sell (ie both the same and the price set the same - both ask or bid).
My log looks like the following
88880 2011.09.29 16:15:43 Buy CloseOrders temp_integer = 25 ticket_nos = 235466286 Lots = 0.03 Price (temp1) = 1.36572 from ~ Hedge_Close_Out
Close Orders ~ Unanticipated error: 129 no error
<<<<<<<<<<<<25 times>>>>>
Close Orders ~ Unanticipated error: 129 no error88881 2011.09.29 16:15:45 Buy CloseOrders - Unable to Close ticket_nos = 235466286 Lots = 0.03
Tried to put close orders in this routine to try and make sure proceedure completed correctly.
Anyone any idea why I get this error and one order fails to complete (i.e. close) ?
PS used the SRC button - normally get the different colors in the code but not here
//================================CloseOrders START====================================+ void CloseOrders(int index,double price,string fromwhere) { string Local_Test_Flag = "YES"; ticket_nos = MOT[index][O_Ticket]; Lots = MOT[index][O_Lots]; temp1 = price; // use temp1 in write_to_log i.e. not local variable if ( Local_Test_Flag == "YES" ) write_to_log(88880,"YES"); for(temp_integer = 25; temp_integer > 0 ; temp_integer--) { OrderClose(ticket_nos, Lots ,price,My_Slippage,Green); temp_string = fromwhere; // use temp_integer in write_to_log i.e. not local variable int my_error = GetLastError(); Sleep(My_Sleep); RefreshRates(); if ( my_error <= 0 ) return(0); if ( my_error > 0 ) FileWrite(My_Handle,"Close Orders ~ Unanticipated error: "+my_error+" "+ErrorDescription(error)); } if ( OrderSelect(ticket_nos,SELECT_BY_TICKET == FALSE) ) return(0); if ( Local_Test_Flag == "YES" ) write_to_log(88881,"YES"); // write_to_log immediately checks GetLatError() return(0); } //================================CloseOrders END======================================+ // first few lines of write to log 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 ) { Print("Location "+location+" Unanticipated error: ", ErrorDescription(error)); FileWrite(My_Handle,"Location "+location+" Unanticipated error: "+error+" "+ErrorDescription(error)); } } if ( My_Test_Flag != "YES" && error == 0 ) return(0); error = 0; switch (location) { case 10000: WTL=WTL+" MC - Enters Manage Contracts"; break; case 10200: WTL=WTL+" ''''''''''''''''''''''' ''''''''''''''''''''''' case 88880: WTL=WTL+" CloseOrders temp_integer = "+temp_integer+" ticket_nos = "+DoubleToStr(ticket_nos,0)+ " Lots = "+DoubleToStr(Lots,2)+" Price (temp1) = "+DoubleToStr(temp1,Digits)+" from ~ "+temp_string; break; case 88881: WTL=WTL+" CloseOrders - Unable to Close ticket_nos = "+DoubleToStr(ticket_nos,0)+ " Lots = "+DoubleToStr(Lots,2); break; ''''''''''''''''''''''' } FileWrite(My_Handle,WTL); FileFlush(My_Handle); if(My_Handle<1) { int err; err=GetLastError(); Print("error(",err,"): ",ErrorDescription(err)); } retu