Problem with an OP_BUYSTOP

 

Good morning, I have a problem opening a OP_BUYSTOP order, I've tried almost everything ... I looked in the forum ... but I can not find a similar problem who can help me, please ask if anyone can help. ..

I have the piece of code below happened, when I calculated the OrderSend with Price (and the result of 1.33823
, I can see with the corresponding Alert ...) I get an error 4107 (Invalid Price), if I remove the comments to the previous line at OrderSend (directly Price = 1.33823) OrderSend instruction works well and opens the order ... it is very strange because Price is set to Double and do not know what can cause the error ...

        

         Alert ("simbol... ", simbolo);
         Alert ("size... ", Size);
         Alert ("open price... ", Price, " ", price_str);
         Alert ("Slippage... ", Slippage);
         Alert ("stop_loss ... ", SL_str);
         Alert ("take profit... ", TP_str);
         Alert ("comments... ", comentarios_orden);
         
         //Price = 1.33823;
   
         Ticket = OrderSend(simbolo,OP_BUYSTOP,Size,Price,Slippage,SL,TP);
         if (Ticket > 0)
            {
            Alert ("Abierta Compra aqui 1 para ", simbolo);
            break;
            }
         Alert ("ticket... ", Ticket);
         int Error_Open = GetLastError();
         switch(Error_Open)
            {
            case 129:Alert("Invalid price. Retrying...");
               RefreshRates();
 
jugivi:

Good morning, I have a problem opening a OP_BUYSTOP order, I've tried almost everything ... I looked in the forum ... but I can not find a similar problem who can help me, please ask if anyone can help. ..

I have the piece of code below happened, when I calculated the OrderSend with Price (and the result of 1.33823
, I can see with the corresponding Alert ...) I get an error 4107 (Invalid Price), if I remove the comments to the previous line at OrderSend (directly Price = 1.33823) OrderSend instruction works well and opens the order ... it is very strange because Price is set to Double and do not know what can cause the error ...

        

Read this:  https://www.mql5.com/en/forum/140682
 
Thank you,  read the post at the link I posted.  It will help you.
 
RaptorUK:
Thank you,  read the post at the link I posted.  It will help you.

Thanks, was enough to ...


Price = NormalizeDouble(Price,Digits);
 
jugivi:

Thanks, was enough to ...

Price = NormalizeDouble(Price,Digits);

Just beware that while NormalizeDouble() may have solved your immediate issue, its use can also lead to other unintended issues.

See:

  Can price != price ?

  Bid/Ask: (No Need) to use NormalizeDouble in OrderSend 

 
Thirteen:

Just beware that while NormalizeDouble() may have solved your immediate issue, its use can also lead to other unintended issues.

See:

  Can price != price ?

  Bid/Ask: (No Need) to use NormalizeDouble in OrderSend 

I don't think either are relevant in this case, the key information from the original post is . . . "when I calculated the OrderSend with Price"
Reason: