Sell Stop and Buy Stop closing

 

Good morning, I have a problem with sell stop and buy stop orders. I create them without stop loss only with take profit but they close by themselves as soon as they open and I don't understand what is happening.


If anyone can help me I would be very grateful. Thanks!

 
fran3r:

Good morning, I have a problem with sell stop and buy stop orders. I create them without stop loss only with take profit but they close by themselves as soon as they open and I don't understand what is happening.


If anyone can help me I would be very grateful. Thanks!

you expect an answer without providing the source code?

 
Paul Anscombe #:

you expect an answer without providing the source code?

double priceBuyStop = SymbolInfoDouble(_Symbol, SYMBOL_ASK) + 50 * _Point;
   double takeProfit = priceBuyStop + 100  * _Point;
   datetime expirationTime = TimeCurrent() + timeOrderExpiredInMinutes * 60; 
   
   if (trade.BuyStop(lotSize, priceBuyStop, _Symbol, NULL, takeProfit, ORDER_TIME_SPECIFIED, expirationTime, "BuyStop Order")){
      Print("Orden BuyStop creada a: ", currentPrice);
   } else{
      Print("Error al crear la orden BuyStop: ", GetLastError());
   }