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

 
Pls check stop level at symbol properties and make sure the price is higher or lower (pending limit or pending stop) than stop level.
 

@Irwan: The threadstarter wrote: "with SL=0 and TP = 0" ;-)


Here my test code: (Snippet) where an Order is set without SL and TP and after successful creation, I add SL and TP. (Only in this case. Not always... ;-) )

 ticket = OrderSend(Symbol(), cmd, lots, inPrice, Slippage, 0, 0, NULL, 333, 0, clrNONE);
      
      if (ticket != -1)
      {
         if (OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES) == true)
         {
            if (OrderModify(ticket, OrderOpenPrice(), sl, tp, NULL, clrNONE) == true)
            {
               _toolManager.SendMessage("Added TP and SL successful.", clrLimeGreen);
            }
            else
            {
               _toolManager.SendMessage("Could not set SL and TP!!", clrRed);
            }
         }
         else
         {
            _toolManager.SendMessage("Could not set SL and TP!", clrRed);
         }
         
      }

Here are the results of the code and the results of manual trading: (From bottom to top)

Terminal Journal

1. I first tried to open an order by code, without SL and TP as a sell stop order.

-> I got the error message Invalid SL or TP.

2. I opened a market order by code

-> Success, but modification of SL and TP after the order was placed failed. (For the moment not so important, because I did not check the min values for SL and TP)

3. I've tested, if the sell stop is the problem and opened a sell stop without TP and SL by hand.

-> Success.

I've tried sell stop orders by code with slippage-values from 0 to 100. All failed.

I must say, that I have never traded futures and maybe there are some things I do not know...
My code works fine for all other instrument types (forex, indices, cfd), but in this special case
I have a problem...

 

  • You should read exact error code with GetLastError() 
  • What is the spread and minimum stop level for this instrument? 

 
Martin Fischer:

@Irwan: The threadstarter wrote: "with SL=0 and TP = 0" ;-)


Here my test code: (Snippet) where an Order is set without SL and TP and after successful creation, I add SL and TP. (Only in this case. Not always... ;-) )

Here are the results of the code and the results of manual trading: (From bottom to top)


1. I first tried to open an order by code, without SL and TP as a sell stop order.

-> I got the error message Invalid SL or TP.

2. I opened a market order by code

-> Success, but modification of SL and TP after the order was placed failed. (For the moment not so important, because I did not check the min values for SL and TP)

3. I've tested, if the sell stop is the problem and opened a sell stop without TP and SL by hand.

-> Success.

I've tried sell stop orders by code with slippage-values from 0 to 100. All failed.

I must say, that I have never traded futures and maybe there are some things I do not know...
My code works fine for all other instrument types (forex, indices, cfd), but in this special case
I have a problem...

The ticksize for this symbol is 1.00, you can use price 1057.61 or 1116.88

Forum on trading, automated trading systems and testing trading strategies

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

Alain Verleyen, 2015.01.08 16:30

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.

A normalized price must always be a multiple of ticksize.
 

Normalized OrderInPrice? Or normalized OrderTakeProfit and/or OrderStopLoss? Or both?

If it's necessary for SL and TP than SL = 0 and/or TP = 0 is not allowed?

Thank you!

Reason: