Download MetaTrader 5

OP_BUYSTOP/OP_SELLSTOP OrderSend with SL=0 and TP=0 return me error 130 (invalid stops!)

To add comments, please log in or register
dream3r
886
dream3r  

Hello everyone,

I am trying to solve the issue with setorder in my code and I don't know whre can be the error!

 The code:

int ticket = OrderSend(Symbol(), type, lot, price, 0, 0, 0, CustomComment, Magic, 0, col);
Print("PUT ORDER: " + IntegerToString(type), ", price=", DoubleToStr(price, _Digits), ", lot=", DoubleToStr(lot, DecimalPoints));

The output:

2015.01.08 08:33:28.102 #FDXH5,M1: err=130, col=3145645, type=4, price=9668.8, lot=0.01, invalid stops
2015.01.08 08:33:28.102 #FDXH5,M1: PUT ORDER: 4, price=9668.8, lot=0.01

 Can you help me please? The same code for OP_SELL and OP_BUY works me fine! 

Thank you in advance! 

Alain Verleyen
Moderator
32025
Alain Verleyen  
dream3r:

Hello everyone,

I am trying to solve the issue with setorder in my code and I don't know whre can be the error!

 The code:

The output:

 Can you help me please? The same code for OP_SELL and OP_BUY works me fine! 

Thank you in advance! 

Where is the code line that output this :

2015.01.08 08:33:28.102 #FDXH5,M1: err=130, col=3145645, type=4, price=9668.8, lot=0.01, invalid stops

Please post a complete sequence of code.

dream3r
886
dream3r  

Yes, sorry. 

I don't know where can be the error. The code is:  

int ticket = OrderSend(Symbol(), type, lot, price, 0, 0, 0, CustomComment, Magic, 0, col);
Print("PUT ORDER: " + IntegerToString(type), ", price=", DoubleToStr(price, _Digits), ", lot=", DoubleToStr(lot, DecimalPoints));
int err = GetLastError();
if (ticket == -1 && err > 0)
 Print("err=", IntegerToString(err), ", col=" + IntegerToString(col), ", type=" + IntegerToString(type), ", price=", DoubleToStr(price, _Digits), ", lot=", DoubleToStr(lot, DecimalPoints), ", ", ErrorDescription(err));
return (ticket);
Alain Verleyen
Moderator
32025
Alain Verleyen  
dream3r:

Yes, sorry. 

I don't know where can be the error. The code is:  

Type=4 is a BUYSTOP. You are trying to place a buystop at 9668.8, what is the current price (Bid/Ask) ?
dream3r
886
dream3r  
angevoyageur:
Type=4 is a BUYSTOP. You are trying to place a buystop at 9668.8, what is the current price (Bid/Ask) ?

Yes, I put it here:

Ask: 9739.0
Bid:  9737.0

The logger: 


 The problem is that the error occurs, but inmediatly, when I tried to do it manually, the order works perfectly. I've tried with SELLSTOP/BUYSTOP and SELLLIMIT/BUYLIMIT and the result was the same: error 130.

Please, I need help to solve it.

Thank you in advance 

Alain Verleyen
Moderator
32025
Alain Verleyen  
dream3r:

Yes, I put it here:

The logger: 


 The problem is that the error occurs, but inmediatly, when I tried to do it manually, the order works perfectly. I've tried with SELLSTOP/BUYSTOP and SELLLIMIT/BUYLIMIT and the result was the same: error 130.

Please, I need help to solve it.

Thank you in advance 

A BUY_STOP needs to be place at a higher price than market price, not lower.

Is your price calculated ? You have to normalize your price in this case.

dream3r
886
dream3r  
angevoyageur:

A BUY_STOP needs to be place at a higher price than market price, not lower.

Is your price calculated ? You have to normalize your price in this case.

Yes, I know that it has to be at a higher price.

The price is calculated and I show it on the print, but in that case, I don't know where is the error.

Someone van help me on that please?
Martin Fischer
12351
Martin Fischer  

Hello,

I've detected the same problem.

Broker: GKFX (DE)

Symbol AALUK_

SYMBOL_TRADE_CALC_MODE = 2

MODE_MARGINCALCMODE = 1

MODE_PROFITCALCMODE = 1

Tooltip on Symbol says : Calculation: Futures.

Manual opening of any order-type is no problem. Opening with OrderSend() fails.
(Invalid S/L or T/P). Tested with and without S/L and T/P parameters.

Please let me know, if you have a solution for it of if we made a mistake with OrderSend() on this symbol-type.

Thank you!

Alain Verleyen
Moderator
32025
Alain Verleyen  
re-run:

Hello,

I've detected the same problem.

Broker: GKFX (DE)

Symbol AALUK_

SYMBOL_TRADE_CALC_MODE = 2

MODE_MARGINCALCMODE = 1

MODE_PROFITCALCMODE = 1

Tooltip on Symbol says : Calculation: Futures.

Manual opening of any order-type is no problem. Opening with OrderSend() fails.
(Invalid S/L or T/P). Tested with and without S/L and T/P parameters.

Please let me know, if you have a solution for it of if we made a mistake with OrderSend() on this symbol-type.

Thank you!

Invalid SL/TP without SL and TP ? Show your code please.
Martin Fischer
12351
Martin Fischer  

Hello,

maybe I found the problem. The error-message does not fit to the problem. ;-)
And my problem could be a wrong calculated lot size. I will check this tomorrow.

Best regards

Aleksei Beliakov
27359
Aleksei Beliakov  
the problem is in the distance from Ask get more than now and your problem will be solved
12
To add comments, please log in or register