openModify() giving error 130

 

Hi all,

this is my first post, so please bear with me. I have read through about 8 posts which were similair to mine, but nothing to help me unfortunately.

I am trying to play around with the expert advice system and have come up with a simple start function as below:

int start()

{

//Open a position

Alert("Placing order");

int currentOrderID = OrderSend(Symbol(),OP_BUY,currentWager,Ask,0,0,0,"Magic",0,0,Green);

Alert("Ask = ", Ask);

double Top = Ask + 0.05;

Alert("Top = ", Top);

double Bottom = Ask - 0.05;

Alert("Bottom = ", Bottom);

OrderSelect(currentOrderID, SELECT_BY_TICKET);

Alert("Market info = ", MarketInfo(Symbol(), MODE_STOPLEVEL));


if(currentOrderID>-1)

{

Alert("Modifying Order");

bool done = OrderModify(currentOrderID, OrderOpenPrice(), Top, Bottom, 0, Green);

if(done)

{

Alert("Order Modified Successfully.");

}

else

{

Alert("Order Modified returned the error of ",GetLastError());

}

Sleep(120000);

}

else

{

Alert("Error");

Alert("OrderSend failed with error #",GetLastError());

Sleep(60000);

return;

}

return;

The asking, stoploss and takeprofit values come out as: 1.4382, 1.3882, 1.4882, which seem fine since I am Buying. Though i still get error 130. I would really appreciate any help you can give me

Thank you very much,

JBason

 

Please use this to post code . . . it makes it easier to read.

 

I suspect that your SL is too close to the market because of this . . .

double Bottom = Ask - 0.05;

. . . increase it to 10 pips and try again, if it works with 10 pips then you know what your problem is. Bear in mind if the SL triggers it is a sell and happens at the Bid price, difference between Bid and Ask is the spread.

Do some reading about Freezlevel and Stoplevel . . . MODE_FREEZELEVEL & MODE_STOPLEVEL here: https://docs.mql4.com/constants/marketinfo