Trade Frustration! Using the MQL function OrderSend
Using the MQL function OrderSend
Like opening a trade on a trading platform. That should be pretty darn easy, shouldn’t it?
Well, turns out it’s not.
OrderSend is a pain in the neck.
OrderSend is the MQL function used to open a trade.
Every MQL programming language I’ve worked with has a few of these. Unwieldy functions that are difficult to work with – and in hindsight seem like they were poorly written.
There are 3 secrets you have to know to use OrderSend correctly:
- The stoploss and takeprofit values are price values, like 1.2345, not offsets like 20 or -50.
- If it’s a Buy order, the price value must be Ask. And if it’s a Sell order, the price value must be Bid.
- When OrderSend fails, it writes an error code to the Journal tab of the MT platform.
OrderSend has a lot parameters, and if any of them are wrong, the trade will not open. It’s so difficult that I had to create a special entry-screen for its parameters.
I actually created a new function named fnOpenOrder. It’s available in the VTS Toolbox, under the Trade menu. (You can read more about the Toolbox here: VTS-Help-Toolbox )
The fnOpenOrder dialog makes it a little easier to open a trade. Hopefully it helps you avoid the frustration most traders experience when they work with OrderSend.
You can read all about fnOpenOrder here: VTS-Help-fnOpenOrder
Also you can see it in action at the 5:52 mark in the EA Wizard Video.