OP_BUYSTOP

 

can someone help, nead to change the normal buy order to buystop, but keep on getting a 130 error


if(LastBar == 1)



{
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 5, Ask - StopLoss * Point,
Ask + TakeProfit*Point, "BuyStop", 12345, 0, Green); prtAlert("EUR/USD: Buying");
if(ticket > 0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("BUYSTOP order opened : ", OrderOpenPrice());

}
else
{
Print("Error opening BUYSTOP order : ", GetLastError());

if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}


}

 
Shadow,

First of all, you should understand the 130 error:

"At placing of a pending order, the open price cannot be too close to the market. The minimal distance of the pending price from the current market one in points can be obtained using the MarketInfo() function with the MODE_STOPLEVEL parameter. In case of false open price of a pending order, the error 130 (ERR_INVALID_STOPS) will be generated." ( https://docs.mql4.com/trading/OrderSend )


Good Luck!
 

You can not put pending order closer then MarketInfo(Symbol(),MODE_LOTSTEP) points to current price (Ask, Bid).

Reason: