When creating a Take Profit for an open position SELL position, a BUY order is created... why ?

 

Hello all,


Whenever there is a SELL opened position, I create a SL and a TP for it:


 
// if the position is a SELL
double posPrice = PositionGetDouble(POSITION_PRICE_CURRENT);
 if (posType == POSITION_TYPE_SELL) {
     // if it has NO Sl
      if(posSl == 0) {
           double sl = posPrice + 50;
           double tp = posPrice - 50;
           // create a Sl and a Tp (it will actually create a new order, a BUY one ! with a sl and tp)
           trade.PositionModify(posTicket, sl, tp);

      }
  }
      


When running the backtester, I can see that it actually creates a BUY order ,  so I don't understand how this BUY order can make profit (0.28) since it's a BUY order and the TP was below the price at which it was initiated...



Any idea ?


Thanks

 
AYMERIC75:

When running the backtester, I can see that it actually creates a BUY order ,  so I don't understand how this BUY order can make profit (0.28) since it's a BUY order and the TP was below the price at which it was initiated...

To close Sell position a Buy position is created. 

 
Yashar Seyyedin #:

To close Sell position a Buy position is created. 

No. 

A buy position is opened by a buy deal and closed by a sell deal.

A sell position is opened by a sell deal and closed by a buy deal.

You shouldn't mix up deals and positions.
 
Tobias Johannes Zimmer #:
sition is op

You are right.

Reason: