Can't open order if set stop/target level - Help needed !!!

 

Dear Coders,

I tried to write a simple code but it doesn't place any order if I set stop/target level on it. The code is below:

if (maxbuy == 0) // Open one order ONLY
  {
    if (Bid <= open_price) // If market goes below open_price then open BUY
     {
      if(TradeIsBusy() < 0) return(-1); // Check to see if Trade context is busy or not
      OrderSend(Symbol(),OP_BUY,1,Bid,3,stop,target,NULL,NULL,0,Red); // stop/target calculated above
      Print("OrderSend failed with error #",GetLastError());
      TradeIsNotBusy();
      maxbuy = 1;
     }
  }    
 
Your broker does not allow sending Stop-loss/Take-profit along with order. You'll have to modify the order with sl and tp after its successful.
 
What error do you get ? You probably have an ECN Broker and need to place the order with TP & SL set to 0 then do an OrderModify to set the TP & SL . . . plenty of stuff here: http://crum.be/ecn
Reason: