Please Help

 
Please help, I can't fix the code for moving pending deals
Can someone help put the code to move the pending deals without showing the error in the picture

Thank you for your help


 
You should know what the error 130 means! Just correct that and make sure (check!!) that it is captured before the modification is sent!
 
void ModifyPendingOrderSar()
{


if(OrderType()==OP_SELLSTOP)C=Red;if(OrderType()==OP_BUYSTOP)C=Lime;

for(int cnt=0;cnt<OrdersTotal();cnt++)
 {
 if( OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
  if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
  {

 if(OrderType()==OP_SELLSTOP||OrderType()==OP_BUYLIMIT)
   {
    if(openprice_SS<Bid-Step*pt&&!CheckStopLoss_Takeprofit(ORDER_TYPE_SELL_STOP,OrderStopLoss(),OrderTakeProfit()))bool k=OrderModify(OrderTicket(),Bid-Step*pt,NormalizeDouble(openprice_SS+StopLoss*pt,Digits),OrderTakeProfit(),0,Red); 
   }
   
   
   if(OrderType()==OP_BUYSTOP||OrderType()==OP_SELLLIMIT){
    if(openprice_BS>Ask+Step*pt&&!CheckStopLoss_Takeprofit(ORDER_TYPE_BUY_STOP,OrderStopLoss(),OrderTakeProfit()))bool h=OrderModify(OrderTicket(),Ask+Step*pt,NormalizeDouble(openprice_BS-StopLoss*pt,Digits),OrderTakeProfit(),0,Lime);
    }  
}
}
}


The problem is with this code and I don't know how to fix it

If you can help put the correct code here and thank you for the help

 
Samir Arman #:


The problem is with this code and I don't know how to fix it

If you can help put the correct code here and thank you for the help

error 130 is related to improper entry sl tp.

1. you try to create sell stop order below current bid price.

2. you try to create sell limit order above current bid price.

3. you try to set stop loss above entry level in buy order.

.

.

.

and all these should be checked before calling OrderModify

 
Yashar Seyyedin #:

error 130 is related to improper entry sl tp.

1. you try to create sell stop order below current bid price.

2. you try to create sell limit order above current bid price.

3. you try to set stop loss above entry level in buy order.

.

.

.

and all these should be checked before calling OrderModify

Can you put the correct code and thanks for the help

 
Samir Arman:

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
Keith Watford #:

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

Thank you

 
Samir Arman #:


The problem is with this code and I don't know how to fix it. 

This section of the forum is for getting help if you want to learn . You need yo address to freelance section for fixing your code 
 
Samir Arman #:The problem is with this code and I don't know how to fix it
void ModifyPendingOrderSar()
{
⋮
 if(OrderType()==OP_SELLSTOP||OrderType()==OP_BUYLIMIT)
   {
    if(openprice_SS<Bid-Step*pt&&!CheckStopLoss_Takeprofit(ORDER_TYPE_SELL_STOP,

There is no such thing in MT4 as ORDER_TYPE_SELL_STOP. You already know there is only OP_SELLSTOP.

 
William Roeder #:

There is no such thing in MT4 as ORDER_TYPE_SELL_STOP. You already know there is only OP_SELLSTOP.

void ModifyPendingOrderSar()
{


if(OrderType()==OP_SELLSTOP)C=Red;if(OrderType()==OP_BUYSTOP)C=Lime;

for(int cnt=0;cnt<OrdersTotal();cnt++)
 {
 if( OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
  if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
  {

 if(OrderType()==OP_SELLSTOP||OrderType()==OP_BUYLIMIT)//NormalizeDouble(openprice_SS+StopLoss*pt,Digits)
   {
    if(!CheckStopLoss_Takeprofit(OP_SELLSTOP,NormalizeDouble(openprice_SS+StopLoss*pt,Digits),OrderTakeProfit())&&openprice_SS<Bid-Step*pt&&OrderModifyCheck(OrderTicket(),Bid-Step*pt,NormalizeDouble(openprice_SS+StopLoss*pt,Digits),OrderTakeProfit()))bool k=OrderModify(OrderTicket(),Bid-Step*pt,NormalizeDouble(openprice_SS+StopLoss*pt,Digits),OrderTakeProfit(),0,Red); 
   }
   
   
   if(OrderType()==OP_BUYSTOP||OrderType()==OP_SELLLIMIT){//NormalizeDouble(openprice_BS-StopLoss*pt,Digits)
    if(!CheckStopLoss_Takeprofit(OP_BUYSTOP,NormalizeDouble(openprice_BS-StopLoss*pt,Digits),OrderTakeProfit())&&openprice_BS>Ask+Step*pt&&OrderModifyCheck(OrderTicket(),Ask+Step*pt,NormalizeDouble(openprice_BS-StopLoss*pt,Digits),OrderTakeProfit()))bool h=OrderModify(OrderTicket(),Ask+Step*pt,NormalizeDouble(openprice_BS-StopLoss*pt,Digits),OrderTakeProfit(),0,Lime);
    }  
}
}
}
Reason: