Confused about stoploss and take profit calculations from tutorials

 

Hi

I've been following the TruthfullTading tutorials on the tutorials thread as they were recommended to me, but I'm confused about differences in how he generates stops. 

AIUI in his Moving average example he uses the following code to calc stoploss that uses the ASK price for a BUy and the Bid price for a Sell. I'm sure I've copied this correctly and I've attached a screen grab to show his versions too.

//check for cross over and buy
  if(fastBuffer[1] <= slowBuffer[1] && fastBuffer[0] >slowBuffer[0] && openTimeBuy!=iTime(_Symbol,PERIOD_CURRENT,0)){
    openTimeBuy =   iTime(_Symbol,PERIOD_CURRENT,0);
    double ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
    double sl =ask -inpStopLoss *SymbolInfoDouble(_Symbol,SYMBOL_POINT);
    double tp =ask +inpTakeProfit  *SymbolInfoDouble(_Symbol,SYMBOL_POINT);
    trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,0.01,ask,sl,tp,"Cross EA");
    }
   
   //check for cross over and sell  
   if(fastBuffer[1] >= slowBuffer[1] && fastBuffer[0] <slowBuffer[0] && openTimeSell!=iTime(_Symbol,PERIOD_CURRENT,0)){
    openTimeSell =   iTime(_Symbol,PERIOD_CURRENT,0);
    double bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);
    double sl =bid +inpStopLoss *SymbolInfoDouble(_Symbol,SYMBOL_POINT);
    double tp =bid -inpTakeProfit  *SymbolInfoDouble(_Symbol,SYMBOL_POINT);
    trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,0.01,bid,sl,tp,"Cross EA");
  }

 However, in the Bollingband example he seems to swap them around and uses the Bid price for a buy and the ask price for a sell.

//check for lower band cross to open a buy position
  if(cntBuy==0 && currentTick.ask<=lowerBuffer[0] && openTimeBuy!=iTime(_Symbol,PERIOD_CURRENT,0)){
    openTimeBuy =   iTime(_Symbol,PERIOD_CURRENT,0);
    double sl   =   currentTick.bid - inpStopLoss * _Point;
    check this because in the moving average video he uses ask price!
    double tp   =   inpTakeProfit==0 ? 0:currentTick.bid + inpTakeProfit * _Point;
    if(!NormalisePrice(sl,sl)) return;
    if(!NormalisePrice(tp,tp)) return;

    trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,InpLotSize,currentTick.ask,sl,tp,"BB EA buy");
   }
  //check for upper band cross to open sell
  if(cntSell==0 && currentTick.bid>=upperBuffer[0] && openTimeSell!=iTime(_Symbol,PERIOD_CURRENT,0)){
    openTimeSell =   iTime(_Symbol,PERIOD_CURRENT,0);
    double sl   =   currentTick.ask + inpStopLoss * _Point;
    double tp   =   inpTakeProfit==0 ? 0 : currentTick.ask - inpTakeProfit * _Point;
    if(!NormalisePrice(sl,sl)) return;
    if(!NormalisePrice(tp,tp)) return;

    trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,InpLotSize,currentTick.bid,sl,tp,"BB EA");
   }

Can anyone please explain why they are different and what the advantages/disadvantages of each is? 

Thank you.

 
pete sw:

Hi

I've been following the TruthfullTading tutorials on the tutorials thread as they were recommended to me, but I'm confused about differences in how he generates stops. 

AIUI in his Moving average example he uses the following code to calc stoploss that uses the ASK price for a BUy and the Bid price for a Sell. I'm sure I've copied this correctly and I've attached a screen grab to show his versions too.

 However, in the Bollingband example he seems to swap them around and uses the Bid price for a buy and the ask price for a sell.

Can anyone please explain why they are different and what the advantages/disadvantages of each is? 

Thank you.

Both are valid, it's up to you to decide how you want to calculate them.
 
Alain Verleyen #:
Both are valid, it's up to you to decide how you want to calculate them.

Hi Alain

Any chance of pointing me in the direction of a reliable resource that explains the advantages/disadvantages to help me learn how I decide?

Thank you.

 

I don't have a source, it's simple logic.

Take the example of a BUY. It's open at ASK price and closed at BID price. You open at 1.2000 for example, the spread is 0.0002 and you want a TP of 10 pips  (0.0010).

If you use the ASK price, your TP will be 1.2010 (ASK at open + 10 pips). Your profit will be 10 pips, but more your TP is far less you have chance to reached it. (the BID has to move 12 pips).

If you use the BID price, your TP will be 1.2008 (BID at open + 10 pips). Your profit will be 8 pips, but as it is closer to your open price, you have more chance to reach it. (the BID has to move 10 pips).

 
Alain Verleyen #:

I don't have a source, it's simple logic.

Take the example of a BUY. It's open at ASK price and closed at BID price. You open at 1.2000 for example, the spread is 0.0002 and you want a TP of 10 pips  (0.0010).

If you use the ASK price, your TP will be 1.2010 (ASK at open + 10 pips). Your profit will be 10 pips, but more your TP is far less you have chance to reached it. (the BID has to move 12 pips).

If you use the BID price, your TP will be 1.2008 (BID at open + 10 pips). Your profit will be 8 pips, but as it is closer to your open price, you have more chance to reach it. (the BID has to move 10 pips).

Thank you that's great. I've done a bit of manual trading, using things like trendline analysis in Tradingview, but never really thought about the difference between the bid and ask price.

Reason: