My script does not work properly

 
I write herein script to open two buy and sell position ,simultaneously. But just first position trigered and second position did not opened. Please help me
#property link "https://www.metaquotes.net/"
int g,m=10;
int start()
{
OrderSend(Symbol(),OP_BUY,0.1,Ask,0,Bid-m*Point,0,NULL,0,0,CLR_NONE);
OrderSend(Symbol(),OP_SELL,0.1,Bid,0,Ask+m*Point,0,NULL,0,0,CLR_NONE);
return(0);
}
 

What error do you get?

int start()
{
int error;
OrderSend(Symbol(),OP_BUY,0.1,Ask,0,Bid-m*Point,0,NULL,0,0,CLR_NONE);
error = GetLastError();
if(error != 0) Print("Error on buy = ", error);
OrderSend(Symbol(),OP_SELL,0.1,Bid,0,Ask+m*Point,0,NULL,0,0,CLR_NONE);
error = GetLastError();
if(error != 0) Print("Error on sell = ", error);
return(0);
}

 
hi,

this is the error , i am having the same problem "2007.10.26 12:07:44 trade USDCHF,M1: Error on sell = 4109"

thanks
Michael
 

ERR_TRADE_NOT_ALLOWED 4109 Trade is not allowed. Enable checkbox "Allow live trading" in the expert properties.

Uh....

Does your Dealer allow long and short positions at the same time?

It opens the long, but not the short?

Close the trades manually, try making the SELL before the BUY, see what happens

Try making the trades manually, see what happens

 
I try your script for 20 times. In majority of times the script work with no error and two hedge positions opened. In two cases ,SELL position opened, but error number 130 reported with terminal and BUY position did not opened. Thanks
Reason: