MQL4 - automated forex trading   /  

Forum

My script does not work properly

Back to topics list To post a new topic, please log in or register

avatar
4
behrouz2007 2007.10.25 22:49 
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 "http://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);
}
article

Error 146 ("Trade context busy") and How to Deal with It

The article deals with conflict-free trading of several experts on one МТ 4 Client Terminal. It will be useful for those who have basic command of working with the terminal and programming in MQL 4.


avatar
2462
phy 2007.10.25 22:59 

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);
}


avatar
2
irey2k 2007.10.26 15:08 
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


avatar
2462
phy 2007.10.26 18:00 

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


avatar
4
behrouz2007 2007.10.26 19:41 
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
Back to topics list  

To add comments, please log in or register