Forex Factory (https://www.forexfactory.com/forum.php)
-   Platform Tech (https://www.forexfactory.com/forumdisplay.php?f=69)
-   -   please please help going mad (https://www.forexfactory.com/showthread.php?t=237966)

censura May 24, 2010 2:29pm | Post# 1

please please help going mad
 
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);
}

CodeMeister May 24, 2010 2:39pm | Post# 2

Try This
 
Values sent to the server must be precise; ie. no trailing decimal digits. You need to normalize the values such as NormalizeDouble(Bid+30*Point, Digits).

sangmane May 24, 2010 3:02pm | Post# 3

try using very big sl/tp, like 1000 point (in 5 digits it equals 100 pip). if you still get error 130 (invalid stop), chances are your broker uses "ECN style" order processing. if that is the case, try using sl/tp = 0
ticket=OrderSend(Symbol(),OP_BUY,1, Ask,3,0,0,"ragstoriches ",080464,0,Green);
then modify it after the order is succeeded

ps: be relax, panic won't solve the problems

censura May 24, 2010 4:47pm | Post# 4

sorry to be thick
 
Values sent to the server must be precise; ie. no trailing decimal digits. You need to normalize the values such as NormalizeDouble(Bid+30*Point, Digits).
do i use it as variable declaration or as assignment ie

sl=NormalizeDouble(Bid+30*point,digits)

ticket=OrderSend(Symbol(),OP_SELL,1,Bid,30,sl,Bid-500*Point,"ragstoriches",080464,0,Green);

thank you

CodeMeister May 24, 2010 5:39pm | Post# 5

Doesn't Matter
 
Either way works.


© Forex Factory