[Need Help] Problem with Sell & SellStop

 

Hello,

I'm writing an EA and i have a problem here:

This is my Send Order:

OrderSend(Tien,ÓP_SELL,Lots[y],NormalizeDouble(GiaS[y],Sothapphan),3,z,NormalizeDouble(GiaTPS[y],Sothapphan),NULL,0,0,clrNONE);

And this is my SellStop Order

OrderSend(Tien,OP_SELLSTOP,LotSs,NormalizeDouble(GiaSs,Sothapphan),3,StopLostSs,GiaS[0]-2*Pips*SoPoint,NULL,0,0,clrNONE);

I set the TopProfit of Send Order is the Price of SellStop Order but when i test the EA by Stratergy Tester when the Market is going down and meet the Profit, the Sell Order didn't close and the SellStop Order is active.


Can anyone explain this for me and help me to fix it? 

I want the Sell Order close & SellStop Order active on the same time


Thank you so much

 
kissmez: I set the TopProfit of Send Order is the Price of SellStop Order but when i test the EA by Stratergy Tester when the Market is going down and meet the Profit, the Sell Order didn't close and the SellStop Order is active.

Can anyone explain this for me and help me to fix it?

  1. You buy at the Ask and sell at the Bid. Your Sell Stop triggered when the Bid reached it. The Ask, hadn't reach that same Take Profit price yet.
  2. If you want a sell order to close at a specific (Bid) price, add the spread to SL/TP. Like wise if you want a pending buy order to open at a specific (Bid) price, add the spread.