Does anyone have a simple buy and sell funtion, i have the following but get errors order send error 130 and am pulling my hair out this is a 5 digit broker. I took this code from the mt4 f1 help so thought it would be fine, i notice when i print Bid, Ask ect i get different digit lengths ie
Bid was 1.4448 and ask was 1.445 and understand that this may be an issue i have set slippage to 30 and take profit to 500 and stoploss to 300 so plent of room i would think - please please help
if(total < 1)
{
if(position == 1)
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-30*Point,Ask+50*Point,"ragstoriches",080464,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}
if(position == -1)
{
ticket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+30*Point,Bid-50*Point,"ragstoriches",080464,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}
}
return(0);
}
Bid was 1.4448 and ask was 1.445 and understand that this may be an issue i have set slippage to 30 and take profit to 500 and stoploss to 300 so plent of room i would think - please please help
if(total < 1)
{
if(position == 1)
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-30*Point,Ask+50*Point,"ragstoriches",080464,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}
if(position == -1)
{
ticket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+30*Point,Bid-50*Point,"ragstoriches",080464,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}
}
return(0);
}