In Part 95 we started a discussion of the OrderReliable group of functions. We’ll continue here.
I use OrderSendReliable() to almost the complete exclusion of OrderSend(). In fact, I can’t think of a single reason to use OrderSend() at all. OrderSendReliable() saves a tremendous amount of coding because it does a lot of the error trapping and retrying of orders.
The OrderReliable group of functions was designed to be “drop in” compatible with the Order functions in MQL4. So, when you replace OrderSend() with OrderSendReliable(), all you’ve got to do it change the function name to effect the change. What does that mean?
int OrderSendReliable(string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic = 0, datetime expiration = 0, color arrow_color = CLR_NONE)
You’ll notice OrderSendReliable() uses the same parameters as OrderSend() function:
int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic = 0, datetime expiration = 0, color arrow_color = CLR_NONE)
So all you have to do to replace OrderSend() is change the function name to OrderSendReliable(). There is a function that is an exception to the rule. While the OrderModifyReliable() function is a direct drop-in replacement for for MQL4’s OrderModify() function, there is also an OrderReliable function called OrderModifyReliableSymbol() that performs additional functions by requiring you to provide the symbol name at the beginning of the parameters that you would normally not include with the OrderModify() parameters. Having the symbol included in the parameters allows the function to fix “problems with stops/take profits which are too close to market, as well as normalization problems.”
The other caveat to using the OrderReliable functions is the OrderReliableLastError() function. This should be used to replace the GetLastError() function due to the fact that GetLastError() clears the last error when you call it and the other OrderReliable functions call GetLastError() during the course of doing their jobs, so you will have to use OrderReliableLastError() to retrieve any errors generated by the other OrderReliable functions.
That wraps our discussion of the OrderReliable functions. Use them in good health. Next time we’ll discuss the validating of pricing information before trying to create orders.
Thanks for your attention and please follow me on Twitter and LinkedIn.
Latest posts by admin (see all)
- How To Trade The Fractal Indicator - April 3, 2017
- How to Use Candlestick Patterns to Start Winning More Trades - March 19, 2017
- Weekly Review Strike 3.0 - December 16, 2016
Winner’s Edge Trading, as seen on: