Too much distance from real price in Open Orders

 

Hello,

I have a problem with to much distance in open Order with the OrderSend() function.

Here a picture:

Often there are taken prices 3 pips over the visible bars in the chart.

Here ist my Code to open Orders:

//my parameters

extern double TakeProfit=60.0;

extern double Lots=0.01;

extern double TrailingStop=35.0;

extern double StopLoss=100.0;

extern int Slippage=3;

if(isCrossed == 1)

{

while(true)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,"EMA_Cross_2",MAGIC,0,Green);

if(ticket<=0)

{

eror=GetLastError();

Print("Error opening BUY order without RefreshRates() function in if not ExistPosition() Abfrage error: ",ErrorDescription(eror));

RefreshRates();

OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,"EMA_Cross_2",MAGIC,0,Green);

eror=GetLastError();

Print("Error opening BUY order after RefreshRates() function in if not ExistPosition() Abfrage error: ",ErrorDescription(eror));

}

else

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

Print("BUY order opened : ",OrderOpenPrice());

break;

}

}//-> End while

return(0);//-> End start()

}//-> End if is Crossed==1

Can you their give me please tips what to do for get reasonable praises ?

 

Hi,

That's normal, when you place a BUY order, you buy at the ask price, which includes a commission. It depends of the broker and seems to be 3 pips in your case (you can get it by calling the OrderCommission() function). Since the charts usually represent bid prices, you buy at ask = bid + 3 pips.

By the way, you should write :

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid-StopLoss*Point,Bid+TakeProfit*Point,"EMA_Cross_2",MAGIC,0,Green);

since you sell at the bid price.

Regards,

Mark

 

Hello Mark,

thank you very much for helping with your tips.

Since I have think that a Buy Order must be made with the Aks Price, but now because you say that I can use the Bid price to for OrderSend() function, I will test it, thank you for the tip.

Regadrs

Echi

Reason: