Greetings! fellow coders.
I have a basic question regarding the OrderSend() function. When coding EA's using MQL4, all order types sent e.g. market orders, LIMIT and STOP orders assume a 'Good-till-Canceled' condition. Is this correct?
If not, is there a pre-defined function already in MQL4 that allows me to send a market order using a 'Fill-or-Kill' condition?
If yes, is there a way to code an OrderSend() function such that it sends the market order as 'Fill-or-Kill'?
I ask because as more brokers are introducing FOK market orders I want to be able to make use of this order type using the EA's I've made coded in MQL4.
I appreciate any assistance.
Limit and stop orders are on a GTC basis unless you explicitly set an expiry time.
Handling of market orders depends on the broker. With most MT4 brokers, market orders are FOK in the sense that you will get either a single complete fill or nothing, but not necessarily at a designated price. The ability to specify a maximum deviation from a specified price depends on the broker and is becoming increasingly uncommon (i.e. many brokers ignore the slippage parameter in OrderSend). A small number of MT4 brokers do partial fills on large orders, i.e. returning multiple tickets in response to a single OrderSend. This is problematic because MT4 has no concept of a "working market order", and therefore no way of cancelling any outstanding portion of an order which is waiting for a fill.
thanks for the response. Suppose an MT4 broker offers both MT4 and a webtrader. On the webtrader when you make an order, you get the option to choose which order filling you want e.g. GTC, FOK or IOC. The broker also specifically states their server and LP allows these 3 types of order fillings. Suppose now with my EA's I want to make use of their FOK order filling. However MQL4 unlike MQL5 doesn't allow us to specify order filling in the code. My next question is, is there a pre-existing function or a function I can code to make FOK orders in MQL4. From my understanding if i just use the OrderSend() function in MQL4, it automatically assumes a GTC filling condition.
again, thanks you any assistance.
My next question is, is there a pre-existing function or a function I can code to make FOK orders in MQL4. From my understanding if i just use the OrderSend() function in MQL4, it automatically assumes a GTC filling condition.
All you can change in MQL4 is the max-deviation parameter for OrderSend, and a broker does not necessarily honour that. Standard terminology such as FOK and IOC isn't particularly applicable to MT4. As I've said above, MT4 orders are usually on an FOK basis in that you get a complete fill or nothing, but you can't necessarily control the price. They aren't really GTC for the simple reason that MT4 doesn't report working market orders, and therefore there's nothing which you can cancel after doing an OrderSend.
While MQL5 provides flags for IOC and FOK, that doesn't mean that a given broker will support both these types of execution. In many cases the broker supports only one, and trying to use the other just leads to orders getting rejected.