Error 130 : invalid stops

 

I get the 130 error from time to time and i cannot figure out why this happens. I place two pending trades - a Buy stop and a Sell stop. The one will get accepted and the other is rejected with an error 130 message.

I use ThinkForex which have no minimum StopLevel. They are a STP broker. My Stop Loss (and Take Profit) are rounded to 5 decimals (which the broker uses). So why does the one pending trade accepted and the other rejected?

Here are the details from my Journal with the results of the error:

 2016.01.04 06:41:18.549    Scalping System EURUSD,H1: open #70680332 sell stop 13.69 EURUSD at 1.08267 sl: 1.08297 tp: 1.08067 ok
2016.01.04 06:41:18.255    Scalping System EURUSD,H1: Ask: 1.08808 Lots: 13.69 Stop: 1.08736 Profit: 1.08966
2016.01.04 06:41:18.255    Scalping System EURUSD,H1: Alert: Open Buy Stop Order - Error 130: invalid stops
2016.01.04 06:41:17.756    Scalping System EURUSD,H1: initialized
2016.01.04 06:41:17.756    Scalping System EURUSD,H1: Spread is 0.00015


Thanking you in advance

 
I would first ask the broker!
 
  1. When I tried stops, I couldn't get them to work. I think it was comparing current market to the TP/SL. Perhaps that problem is back; try setting the pending first and then set the stops.
  2. There is no reason to use pending orders in a EA. Humans can't look at the market continuously, EAs can. Just wait until the market reaches your price.
  3. My Stop Loss (and Take Profit) are rounded to 5 decimals
 
Thank you WHRoeder for that very helpful response. I will certainly make use of your recommendations and advice!
 

"No reasons for EAs to use pending orders" .... sure? 

1. A pending limit order is executed as limit, an EA opens at market. In other words: The higher the precision, the lower the slippage the higher the gained profit.

2. A pending order stays on brokers server even if you are disconnected. In other words: The higher the security the higher the gained profit.

And there are many reasons more why the usage of pending orders is much better than only using market oders. And btw, that is what the TO asked for and I guess he got a reason to use pending orders. What you suggested is a local software based version of MIT orders. There are reasons for MIT orders, sometimes in special cases, but sureley not in general.

My suggestion for the TO is, write a class that manages virtual orders without being affected from success of placing an order physically. If an order could not be sent, the class should optionally still have the option to execute those orders as market orders. This way the main part of your EA doesn't need to bother with such problems but you still get the advantages of especially limit orders in probably 99% of all cases.

 
Doerk Hilger:

"No reasons for EAs to use pending orders" .... sure? 

1. A pending limit order is executed as limit, an EA opens at market. In other words: The higher the precision, the lower the slippage the higher the gained profit.

2. A pending order stays on brokers server even if you are disconnected. In other words: The higher the security the higher the gained profit.

Yes I'm sure!
  1. Most people use stops not limits. A limit opens at that price, what if the market continues? The EA could have waited and got a better price, your limit didn't lesser "the gained profit."
  2. Do you really want to open when the EA is disconnected, can't trail, can't close the order? You had better be using a fixed TP.
 
Doerk Hilger: "No reasons for EAs to use pending orders" .... sure? 

1. A pending limit order is executed as limit, an EA opens at market. In other words: The higher the precision, the lower the slippage the higher the gained profit.

2. A pending order stays on brokers server even if you are disconnected. In other words: The higher the security the higher the gained profit.

And there are many reasons more why the usage of pending orders is much better than only using market oders. And btw, that is what the TO asked for and I guess he got a reason to use pending orders. What you suggested is a local software based version of MIT orders. There are reasons for MIT orders, sometimes in special cases, but sureley not in general.

My suggestion for the TO is, write a class that manages virtual orders without being affected from success of placing an order physically. If an order could not be sent, the class should optionally still have the option to execute those orders as market orders. This way the main part of your EA doesn't need to bother with such problems but you still get the advantages of especially limit orders in probably 99% of all cases.

whroeder1: Yes I'm sure!
  1. Most people use stops not limits. A limit opens at that price, what if the market continues? The EA could have waited and got a better price, your limit didn't lesser "the gained profit."
  2. Do you really want to open when the EA is disconnected, can't trail, can't close the order? You had better be using a fixed TP.

I too agree with WHRoeder on this subject of using Market orders instead of Pending orders, but those that share this opinion are a minority on this forum. The vast majority of users (beginners and pros), favour the use of Pending orders in EAs.

I once had a heated discussion with a certain moderator here, on this very subject, despite providing detailed arguments to support the premise but neither side swayed on their respective opinions. Being in the minority, does not make our opinion invalid or incorrect. It just means that we lack the "weight" to make it be considered having merit instead of it being brushed off.

 
Well if you want to set up a grid system with 10 or more triggers then placing pending orders can make it a lot easier so i think it depends upon the situation.
 

The point discussed being:

There is no reason to use pending orders in a EA.

This is so obviously wrong, what could be a valid reason to discuss about it ? This is a programmer opinion, everyone is free to have an opinion, even wrong. If we talk about facts, that's an other matter.

Reason: