OrderModify error 130 on this code.

 

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);

}

 
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.
 
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);
 

What part of "not the Ask" was unclear?

 
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.

 
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?
Reason: