- 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.
- 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.
- My Stop Loss (and Take Profit) are rounded to 5 decimals
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()
- Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it.
It's use is always wrong
- SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
- Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
- Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
"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. 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.
- 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."
- 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.
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.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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