Download MetaTrader 5

OrderModify error 130 on this code.

To add comments, please log in or register
cape1354
188
cape1354  

hi guys.

I'm trying to modify an Order, but I always get Error #130.

I looked for other texts, but ...

Different from this code, it is difficult to understand and apply.

So I raise my code.

Please let me know based on this code.


extern double initial_Lots = 1.0;            
extern int MagicNo = 1234;
extern double TakeProfit = 50;
extern double StopLoss =30;

int start()
  {
//+------------------------------------------------------------------+
//| Modify                                                           |
//+------------------------------------------------------------------+
          
for(cnt=0;cnt<total;cnt++) //Target open order currently open
 {
   if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)==true)

   {
    if(OrderMagicNumber()==MagicNo && OrderSymbol() == Symbol())
    //Check the magic number and pair
      {
         if(OrderType() == OP_BUY)
            {if(OrderStopLoss()==0 && OrderTakeProfit() == 0)
              
              {ticketM = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-StopLoss*Point,OrderOpenPrice()+TakeProfit*Point,0,Blue); 
              //Change the order with new properties
              return(0);
              }
            }
          
       }
   }
 return(0);
 } 

return(0);

}

whroeder1
16751
whroeder1  
You buy at the Ask and sell at the Bid. You are including the spread with your OOP-SL, thus reducing the amount below 30 points.
cape1354
188
cape1354  
whroeder1:
You buy at the Ask and sell at the Bid. You are including the spread with your OOP-SL, thus reducing the amount below 30 points.


However, it still shows errors 130 


OrderModify(OrderTicket(),OrderOpenPrice(),Ask-StopLoss*Point*10,Ask+TakeProfit*Point*10,0,Blue);
whroeder1
16751
whroeder1  

What part of "not the Ask" was unclear?

cape1354
188
cape1354  
whroeder1:

What part of "not the Ask" was unclear?


Could you explain it based on the above code?

Since I am a beginner, it is difficult to apply the word to the code.

whroeder1
16751
whroeder1  
cape1354: Could you explain it based on the above code?
OrderModify(OrderTicket(),OrderOpenPrice(),Ask-StopLoss*Point*10,Ask+TakeProfit*Point*10,0,Blue);
Not the Ask. Not the Ask. What part of "not the Ask" was unclear?
To add comments, please log in or register