error modifying an order

 

Hello,


I`m trying to modify a bunch of "buy stop" orders, unfortunately I can't get it to happen ( return error 1, wrong price ? ), I want to modify the Buy price of those buy stop orders.

Any ideas where I`m doing things wrong ?


here is my code :



if ((Ask >= High[1]) && (OrdersTotal()>0))

{

for(int i=1; i<=OrdersTotal(); i++)

{

if (OrderSelect(i-1,SELECT_BY_POS)==true)

{

int Tip=OrderType();

int Ticket=OrderTicket();

OrderModify(Ticket,NormalizeDouble(High[1]+2*Point, Digits),OrderStopLoss(),OrderTakeProfit(),0,Blue);

Print(GetLastError());

}

}


}

 
Replace
OrderModify(Ticket,NormalizeDouble(High[1]+2*Point, Digits),OrderStopLoss(),OrderTakeProfit(),0,Blue);
to
if(Tip>1)OrderModify(Ticket,NormalizeDouble(High[1]+2*Point, Digits),OrderStopLoss(),OrderTakeProfit(),0,Blue);
 
Roger:
Replace
OrderModify(Ticket,NormalizeDouble(High[1]+2*Point, Digits),OrderStopLoss(),OrderTakeProfit(),0,Blue);
to
if(Tip>1)OrderModify(Ticket,NormalizeDouble(High[1]+2*Point, Digits),OrderStopLoss(),OrderTakeProfit(),0,Blue);

Did the trick, thank you very much !

 
Will fail also once OrderTakeProfit is below(buy) new price+MarketInfo( Symbol(), MODE_STOPLEVEL )*Point
Reason: