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 ok2016.01.04 06:41:18.255 Scalping System EURUSD,H1: Ask: 1.08808 Lots: 13.69 Stop: 1.08736 Profit: 1.089662016.01.04 06:41:18.255 Scalping System EURUSD,H1: Alert: Open Buy Stop Order - Error 130: invalid stops2016.01.04 06:41:17.756 Scalping System EURUSD,H1: initialized2016.01.04 06:41:17.756 Scalping System EURUSD,H1: Spread is 0.00015
Thanking you in advance
There is Tick, PIP, and Point. They are all different in general. A tick is the smallest change of price. A Point is the least significant digit quoted. In currencies a pip is defined as 0.0001 (or for JPY 0.01)
On a 4 digit broker a point (0.0001) = pip (0.0001). [JPY 0.01 == 0.01] On a 5 digit broker a point (0.00001) = 1/10 pip (0.00010/10). Just because you quote an extra digit doesn't change the value of a pip. (0.0001 == 0.00010) EA's must adjust pips to points (for mq4.) In currencies a tick is a point. Price can change by least significant digit (1.23456 -> 1.23457)
In metals a Tick is still the smallest change but is larger than a point. If price can change from 123.25 to 123.50, you have a TickSize of 0.25 and a point of 0.01. Pip has no meaning.
This is why you don't use TickValue by itself. Only as a ratio with TickSize. See DeltaValuePerLot()
"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.
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.
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.