Function: OrderSend()return -1

 

HI, all

int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,5,0,0,"macd sample",1,0,Green);

string tktstring = ticket;
MessageBox(tktstring,"错误",1);
string errstr = GetLastError();
MessageBox(ErrorDescription(errstr),"错误",1);

TICKET = -1

ERROR Description = no error

please help me, thanks!

 

Please use this to post code . . . it makes it easier to read.

What is the error number returned ? You are passing ErrorDescription a string, should it take a string or an int ?

 
stone35:

HI, all

int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,5,0,0,"macd sample",1,0,Green);

string tktstring = ticket;
MessageBox(tktstring,"错误",1);
string errstr = GetLastError();
MessageBox(ErrorDescription(errstr),"错误",1);

TICKET = -1

ERROR Description = no error

please help me, thanks!

How did you get those cute chinese characters into Editor? First time seeing this, interesting.
 
int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,5,0,0,"macd sample",1,0,Green);
string tktstring = ticket;
MessageBox(tktstring,"错误",1);
string errstr = GetLastError();
Capture the last error BEFORE you loose it with messageBox.
int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,5,0,0,"macd sample",1,0,Green);
string errstr = GetLastError(); // Capture immediately
string tktstring = ticket;
MessageBox(tktstring,"错误",1);
Why use a message box when alert is just as convenient?
Reason: