I get "invalid stops" for no reason!

 

This is a very simple code, yet not working! I'll be happy if someone could help me with this noobie thread :)

The code is:

int start()
  {
double TP = 20;
double SL = 20;
//----
   if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price?    ",
                 "Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
//----  
   int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask - SL*Point*10,Ask + TP*Point*10,"expert comment",255,0,Green);
   Alert(Ask - SL*Point*10);
   Alert(Ask);
   Alert(Ask + TP*Point*10);
   if(ticket<1)
     {
      int error=GetLastError();
      Alert("Error = ",ErrorDescription(error));
      return;
     }
//----
   OrderPrint();
   return(0);

I add it to GBPJPY, and the alert print for example thos values:

"""

135.012

135.212

135.412

Error = invalid stops

"""

Everything spoused to alright, can anyone help?

Almog

 
can anyone help me do my first steps? please?
 

If this is an ECN broker, you may not be able to put an order on with stops?

Try zero for SL & TP with OrderSend and then do an OrderModify on the resulting ticket

Also try wider Slippage if this is a sub-pip account

-BB-

 

You turned us all off by stating that it happened "for no reason". So there was no reason to find.

Check if you can actually place your stops in your OrderSend() or if you need to set them as 0 first and subsequently select the order using OrderSelect() and modify the stops using OrderModify(). You can check by attempting to place the order manually using the MT4 user interface. If 'Instant Execution' is not available, only 'Market Execution' and stop fields are greyed out, then you'll need to do it the difficult way as described above. Or change broker if you don't like being naked in the market at any stage.

If that doesn't answer your question, then report MarketInfo(Symbol(),MODE_STOPLEVEL) make sure you are at least this distance from the entry price (ensuring that you aren't out in your calcs by a factor of 10 due to the number of decimal places in use).

And for dear sake use the forum search facility. This question has been asked more times than enough.

CB

 

many thanks you two!

Next time I will be better asker :)

Reason: