why am i getting this error for order modify ?

 
  if(  OrderMagicNumber()==2222)
                {
                 if(Ask<=OrderOpenPrice()-.003 && OrderOpenPrice()-.001<OrderStopLoss()
                     && OrderStopLoss()>OrderOpenPrice()-.0009)
                  {    bool shortOrderModify=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-.001,OrderTakeProfit(),0,clrYellow);
                     if(!shortOrderModify) 
                       Print("Error in OrderModify. Error code=",GetLastError()); 
                     else 
                       Print("Order modified successfully.");   
                   }

hi appreciate it so much if you help me with this error on this code.

its a short trade with magic # of 2222

totally im trying to say if ask is 30 pips bellow order open price, put stoploss 10 pips bellow order open price(20pip above ask), so there shouldnt be problem with 

SYMBOL_TRADE_STOPS_LEVEL because stop level is 3pips away and my code is putting sl 20pips away but still there is 130error which is invalid stops. 

here is the code:

 if(  OrderMagicNumber()==2222)

                {

                 if(Bid<=OrderOpenPrice()-.003 && OrderOpenPrice()-.001<OrderStopLoss()

                     && OrderStopLoss()>OrderOpenPrice()-.0009)

                  {                   bool shortOrderModify=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-.001,5),OrderTakeProfit(),0,clrYellow);

                     if(!shortOrderModify) 

                       Print("Error in OrderModify. Error code=",GetLastError()); 

                     else 

                       Print("Order modified successfully.");   

                   }

here is the error:

 OrderModify error 130


 
  1. Please do a search before posting. There are already too many threads about the same issue. Please read them.
  2. Next time, please post in the MT4/MQL4 section.
  3. Please edit your post (don't create a new post) and replace your code properly (with "</>" or Alt-S), or attach the original file directly with the "+ Attach file" button below the text box.

    NB! Very important! DO NOT create a new post. EDIT your original post.

 
Fernando Carreiro #:
  1. Please do a search before posting. There are already too many threads about the same issue. Please read them.
  2. Next time, please post in the MT4/MQL4 section.
  3. Also ...

You can reattach gifs i think the server caches them , you are not increasing the load

Farid Hassan Yari:

hi appreciate it so much if you help me with this error on this code.

here is the code:

 if(  OrderMagicNumber()==2222)

                {

                 if(Bid<=OrderOpenPrice()-.003 && OrderOpenPrice()-.001<OrderStopLoss()

                     && OrderStopLoss()>OrderOpenPrice()-.0009)

                  {                   bool shortOrderModify=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-.001,5),OrderTakeProfit(),0,clrYellow);

                     if(!shortOrderModify) 

                       Print("Error in OrderModify. Error code=",GetLastError()); 

                     else 

                       Print("Order modified successfully.");   

                   }

here is the error:

 OrderModify error 130


You are not checking for the direction of the trade but you are also not checking for the stop level limit , are you trying to create a trailing function ?

 

done sir as you said.

Fernando Carreiro #:

  1. Please do a search before posting. There are already too many threads about the same issue. Please read them.
  2. Next time, please post in the MT4/MQL4 section.
  3. Also ...

done sir , as you said

 
Lorentzos Roussos #: You can reattach gifs i think the server caches them , you are not increasing the load

And what is your point? Whether I copy/paste it or use a pocket, the message's effect is the same. I have used both methods. It just depends on my mood.

 
Farid Hassan Yari #: done sir , as you said
Edit it properly, please! And remember to go read the other linked posts.
 
Fernando Carreiro #:

And what is your point? Whether I copy/paste it or use a pocket, the message's effect is the same. I have used both methods. It just depends on my mood.

ow , i thought you were trying to not crash mql5  😂 , anyway , if you attach it its more readable ,in my opinion , unless the user is familiar with reddit

 
@Lorentzos Roussos #: ow , i thought you were trying to not crash mql5  😂 , anyway , if you attach it its more readable ,in my opinion , unless the user is familiar with reddit

Done!

 
  1. Farid Hassan Yari #: done sir , as you said

    Nope, you edited one section but not the other. Are they the same, are they supposed to be different?

  2. Post in the correct place. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  3.  if(  OrderMagicNumber()==2222)
                    {

    Your posted code is without context. You can not use any Trade Functions until you first select an order. Did you? Always post all relevant code (using Code button) or attach the source file.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

 

Don't double post! You already had this thread open.
          General rules and best pratices of the Forum. - General - MQL5 programming forum (2017)