OrderSend Error 130

 

I am receiving an error when attempting to open a Long position:


OrderSend Error 130

Error Opening Long Order: 130


Here is the code, which was modified from a expert advisor that can open trades without error. So I'm not sure why I'm receiving this error.


if(BarClose<Bollinger_Lower && trend<0) // Closing price is less than the Bollinger upper line
{
// if(trend<0) // Trend is down
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TrailingStop,0,"Counter Trend: Long Order Placed",16384,0,Green); // Open Long order

if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening LONG order : ",GetLastError());
return(0);
}
}
return(0);
}

 
ERR_INVALID_STOPS 130 Invalid stops.

Verify your stop value is correct, and if still a problem, Normalized.

Print("----------------------------------stop value is ", Ask-TrailingStop);

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TrailingStop,0,"Counter Trend: Long Order Placed",16384,0,Green); // Open Long order

 

(1) Ask-TrailingStop

Your Ask might be say 1.340 on the EUR/USD for example. What is the value of your TrailingStop? It must be something like 0.0010 or 0.0020 or 0.0011 or 0.133 or etecetera. You are trying to subtract 0.0001's and not integers such as 10, 20, 11, etc.

If you want TrailingStop to be an integer a user enters, such as 10 for instance, then you have to make it 0.0010 first in order to subtract it from Ask. You can do this by the following: TrailingStop * Point. Point on the EURUSD == 0.0001. So you might want to change your code to the following:

Ask-(TrailingStop * Point), which is the same as Ask-TrailingStop * Point.

Below is code from one of my scripts, so you can see how one can do this.

int Stoploss = 30;

.

.

.

OrderSend(Symbol(),OP_BUY,dLotSize, Ask, 3,Ask - Stoploss*Point, Ask + Takeprofit*Point, strOrderComment, MAGIC_ID, 0, Green); // Open Buy Order

Hope this works.

-- ssbForex