Include spread for SL and TP

 

hi guys

i thought i had this correct, and now i am doubting myself.

I know we enter a buy at ask and therefore close SL and TP at bid and enter short at bid and close SL and TP at Ask.

However my entry line, SL line and TP line are calculated off the bid. I have made no allowance for spread in this calculation so the entry line, sl line and tp line for a buy trade are still at the Bid price. (TP and SL are equal distant from EL ie 1:1)

Would I be better off changing the calculation of these lines to be based at the Ask, or just include the spread in the ordersend?

(my thoughts are to accommodate this in the ordersend because otherwise if the spread changes whilst calculating each line, i could end up with a situation where the SL pips does not equal the TP pips. The difference between EL and SL go into my risk calculation for position sizing, so i need to have this correct to make sure I maintain 1:1)

at the moment the entry code is:

///buyprice function

double buyprice ()
{
RefreshRates();
point_2 =Point/2;
return (Ask + point_2);
}

///sellprice function
double sellprice ()
{
RefreshRates();
point_2 =Point/2;
return (Bid +point_2);
}

/////// Trade Entry //////
//buytrade
if ((EL()+pips2dbl) - buyprice() < Point/2) // so if Ask is greater than the (EL line + one point)

OpenBuyOrder(LotSize(),SL(),TP());


//selltrade
if (sellprice() - (EL()-pips2dbl) < Point/2) // so if Bid is less than (EL line - one point)
OpenSellOrder(LotSize(),SL(),TP());



/////Ordersend function

// buy trade
BuyTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage*pips2points,(SL()-pips2dbl),(TP()+pips2dbl+Spread()),commt+MagicNumber,MagicNumber,0,Green);

// sell trade
SellTicket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slippage*pips2points,(SL()+pips2dbl),(TP()-pips2dbl-Spread()),commt+MagicNumber,MagicNumber,0,Red);

I am now thinking that the buy trade needs to have the Spread included for both SL and TP = (SL()-pips2dbl -Spread()),(TP()+pips2dbl+Spread())

and the sell order does not need to have the spread at all = (SL()+pips2dbl),(TP()-pips2dbl)

Would that be more correct?

(i use pips2dbl to just give me one point - so one point above or below my TP and SL)

I have added print statments and then done the calc manually in excel using the outputs, but as i say am doubting myself.

 

For a Buy you've already paid the spread (brought at the Ask.) Set the stops relative to the bid, which is where the market is the moment the order is opened.

For a Sell, you pay the spread when you close. The stops are relative to the Ask == Bid+spread. If you set them relative to the Bid you have larger stops (the spread) on buys and smaller stops on sells.

 
WHRoeder:

For a Buy you've already paid the spread (brought at the Ask.) Set the stops relative to the bid, which is where the market is the moment the order is opened.

For a Sell, you pay the spread when you close. The stops are relative to the Ask == Bid+spread. If you set them relative to the Bid you have larger stops (the spread) on buys and smaller stops on sells.


thanks WHR.

so if i have understood correctly then i need to amend as below? so only the sell trades have the spread inc for TP and SL

// buy trade
BuyTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage*pips2points,(SL()-pips2dbl),(TP()+pips2dbl),commt+MagicNumber,MagicNumber,0,Green);

// sell trade
SellTicket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slippage*pips2points,(SL()+pips2dbl+Spread()),(TP()-pips2dbl-Spread()),commt+MagicNumber,MagicNumber,0,Red);

i did a test where i placed limit orders instead of mkt orders to make sure the entry was the EL line and therefore equal distant.

i printed some examples and for the buy trades

no of pips
enter 1.54262
sl 1.54145 0.00117
tp 1.54379 0.00117

but for the sell trades i end up with a slight difference in the number of pips from EL to SL and EL to TP



no of pips
enter 1.52526
sl 1.52651 0.00125
tp 1.52402 0.00124

any ideas what the 0.00001 difference is for the sell trades? it is the same fro all sells.

Reason: