Problem in OrderSend

 

Hello!

Sometime, I've a problem with OrderSend Function when i try to open at same time a Buy and a Sell Order. The platform (not the EA) answer me that one of two order was open in Buy (instead of Sell) or vice versa.

I'm sure that not is a problem of my EA, because it is able to open Buy and Sell operation at same time in the majority of cases.

Here the log from platform:

14:35:05 EXPERT GOLD,M5: open #73197577 buy 19.35 GOLD at 1317.35 ok

14:35:05 EXPERT GOLD,M5: open #73197578 buy (instead of sell) 19.35 GOLD at 1317.35 ok


thanks in advance.

R.

 
Redray:

Hello!

Sometime, I've a problem with OrderSend Function when i try to open at same time a Buy and a Sell Order. The platform (not the EA) answer me that one of two order was open in Buy (instead of Sell) or vice versa.

I'm sure that not is a problem of my EA, because it is able to open Buy and Sell operation at same time in the majority of cases.

Here the log from platform:

14:35:05 EXPERT GOLD,M5: open #73197577 buy 19.35 GOLD at 1317.35 ok

14:35:05 EXPERT GOLD,M5: open #73197578 buy (instead of sell) 19.35 GOLD at 1317.35 ok


thanks in advance.

R.

Personally, I am sure it's a problem with your EA.

Please show the relevant code if you need help.

 

ok! this is the portion of code that open position:

digit = MarketInfo(Symbol(),MODE_DIGITS);

if(cmd == 0) { price = NormalizeDouble(Ask,digit); takeprofit=0; stoploss=0; expiration=0; }

if(cmd == 1) { price = NormalizeDouble(Bid,digit); takeprofit=0; stoploss=0; expiration=0; }

cross = Symbol();
// Open
exec = OrderSend(cross,cmd,volume, price,slippage,stoploss, takeprofit,comment,magic, expiration,arrow_color);
if(exec != -1)
{
//some code
}
else{
err=GetLastError();
Print("Unable to open Position: Error: ", ErrorDescription(err));
}

All order are at Market, stoploss and takeprofit are set to zero, cross

Thanks!

 
Redray:

ok! this is the portion of code that open position:

digit = MarketInfo(Symbol(),MODE_DIGITS);

if(cmd == 0) { price = NormalizeDouble(Ask,digit); takeprofit=0; stoploss=0; expiration=0; }

if(cmd == 1) { price = NormalizeDouble(Bid,digit); takeprofit=0; stoploss=0; expiration=0; }

cross = Symbol();
// Open
exec = OrderSend(cross,cmd,volume, price,slippage,stoploss, takeprofit,comment,magic, expiration,arrow_color);
if(exec != -1)
{
//some code
}
else{
err=GetLastError();
Print("Unable to open Position: Error: ", ErrorDescription(err));
}

All order are at Market, stoploss and takeprofit are set to zero, cross

Thanks!


That code does not open a buy and a sell at the same time.

It opens a single trade dependant on the value of variable cmd

 

in my opinion still missing some code in order to understand where the problem is

for instance the logic behind "cmd"

maybe that's where the problem is

perhaps you send by mistake OP_BUY instead of OP_SELL

WHRoeder 2013.11.26 14:00 #


Play video
Please edit your post.
For large amounts of code, attach it.
 

Ok, i explain in detail my code, but i can't upload it for entire.

In my code, i read tick by tick if, in a common folder with another program, there is a file named OpenOrderBuy and a file named OpenOrderSell. In some conditions, verified by the other program, the other application create this two files at the same time.

My EA, if files exist, simply read in sequence both files and open position. For Example, the logic behind "cmd"is too simple, in fact this value is readed from OpenOrderBuy or OpenOrderSell, then converted in integer (by mql4 books, OP_BUY and OP_SELL are enum, then i can substitute it with 0 or 1 ).

The same things for the other values needed to open the operation.

The code in my previous post is duplicated and executed only if OpenOrderBuy file and OpenOrderSell exist.

This technique worked well until the upgrade of the platform to build 600. From this update i've some problem like this and "invalid price" error.

 
Redray:

From this update i've some problem like this and "invalid price" error.


try to RefreshRates between the 2 OrderSend
 
Redray:

Ok, i explain in detail my code, but i can't upload it for entire.

In my code, i read tick by tick if, in a common folder with another program, there is a file named OpenOrderBuy and a file named OpenOrderSell. In some conditions, verified by the other program, the other application create this two files at the same time.

My EA, if files exist, simply read in sequence both files and open position. For Example, the logic behind "cmd"is too simple, in fact this value is readed from OpenOrderBuy or OpenOrderSell, then converted in integer (by mql4 books, OP_BUY and OP_SELL are enum, then i can substitute it with 0 or 1 ).

The same things for the other values needed to open the operation.

The code in my previous post is duplicated and executed only if OpenOrderBuy file and OpenOrderSell exist.

This technique worked well until the upgrade of the platform to build 600. From this update i've some problem like this and "invalid price" error.


Then have 2 blocks of code, you cannot have a simple single block of code open 2 opposite orders when it is only sent either OP_BUY or OP_SELL
Reason: