Order types in practice
8 minute read
In this article, we’ll go through the order types in MT4: the Market Order, the Pending Limit Order, and the Pending Stop Order. We’ll also give a few little insights that may not have crossed your mind before, when using each of these order types. We’ll end with what matters in practice, especially for algo trading producers or developers.
For the rest of this article, similar to our previous articles, we’ll use the word “stock” to refer to the “thing” that you’re buying or selling. The reason we do this is because we don’t want to complicate things by using words like “future” or “derivative” – these terms will only hinder comprehension at this point, creating blockages in learning. For now, forget the jargon, and let’s use “stock” to describe the stuff that we’re buying and selling on a chart. It doesn’t matter if this “stuff” is a ‘real item’ or a ‘future outcome’; the name that the finance industry gives it is irrelevant at this stage. Now, let’s get onto it.
Practical definitions
First of all, let’s cover the definitions of each order type.
A Market Order asks the broker to purchase for you some stock at “whatever the market price is”. For example, if you place a Buy Market Order for an iPhone, you say “I want to buy an iPhone right now, at whatever Apple’s price tag is”. The converse example: if you place a Sell Market Order, you say “I will sell my iPhone at whatever price someone’s willing to pay for it right now”. Of course in reality, we check the market price first, before we make this statement; in other words, we check the spread. If you don’t know what the spread is, be sure to read ‘What is the spread: explained simply’.
A Pending Limit Order with your Price attached to it asks the broker to purchase only once it’s affordable at your Price or better. “Better” means cheaper for a buyer, and more expensive for a seller, because obviously it’s better for a buyer to get something cheaper, and it’s better for a seller to sell something for more expensive. For example, let’s say the iPhone’s price tag is $1000 at the Apple Store. If you place a Pending Buy Limit Order at $800 for an iPhone, you say “don’t buy anything right now, wait till Apple asks for $800 or less, then buy; because $800 is my budget limit”. Conversely, if you want to sell your iPhone and place a Pending Sell Limit Order at $1100, you say “don’t sell right now, wait till a buyer can afford to pay me $1100 or more, then sell it to them”.
A Pending Stop Order with your Price attached to it asks the broker to purchase only once you can do so, at your Price or worse. “Worse” means more expensive for a buyer, and cheaper for a seller. For example, if you place a Pending Buy Stop Order at $2000 for an iPhone, you say “don’t buy anything right now, wait till Apple asks for $2000 or more, and then buy”. Conversely, if you place a Pending Sell Stop Order at $500, you say “don’t sell anything right now, wait till some buyer wants to pay me $500 or less, then sell it to them”. You’d immediately sell off your iPhone for $1 if that was the highest bidder.
A Pending Stop Order sounds silly; why would you want to use it and deliberately confirm that you’d accept a worse price? Well, yes, this type of order makes not much economic sense for an initial purchase. It’s traditionally relevant in combination with other order types to perform a protection function. The simplest example is the ‘Stop Loss’ line – this line is actually a Pending Stop Order, which tells the broker to ‘close’ or sell-back your stock to the market, if the price gets worse than a certain level. So you see, traditionally, if you weren’t using a platform with a ‘Stop Loss’ line, and you were phoning up your broker with instructions to buy and sell stuff for you instead, you might actually instruct them with a Pending Stop Order to sell-back all your volume if the price gets bad. And this would be equivalent to setting a Stop Loss using modern platforms. This brings us to the next section on what order types actually matter for robot developers these days.
What actually matters
As a robot developer, you’ll find that the most relevant order type is the Market Order, and here’s why.
In practice, when sending a Market Order, a Price is still sent in the algorithm, indicating the price at which you believe is the market price that you’ll be purchasing at. Theoretically a Market Order instruction says to accept whatever price is on the market at the moment, so technically the broker can purchase part of your volume at the market price, then keep on buying the rest of your requested volume at the next worse price. Based on your instructions, you accept any market price, you just want to buy right now.
However, despite this sounding bad, usually the broker’s system will at least use the Price sent along with a robot’s Market Order instruction as an integrity check to make sure you’re informed about the current market price and seeing what they’re seeing.
In addition to that, traders requesting robot development will often incorporate a request to developers for a spread-size confirmation. That is, to check if the spread is under a certain size before buying.
These three ideas combined – a Market Order, a Price integrity check, and a spread-size confirmation – is good enough to ensure that an order will only open at a price around our expectations, or not at all.
The other utility that’s relevant to help with order prices opening at an expected level is the ‘slippage’ parameter. This parameter is sent to the broker with a Market Order instruction. At MQL4Solutions, we see that the idea of ‘slippage’ has different interpretations and explanations over the web. But we won’t get into that now. In the context of MT4, the term ‘slippage’ is most often used to refer to an order opening at a price that deviates a bit from what was requested. Setting a slippage parameter to ’10’ supposedly tells the broker that you’re ok with them buying you the stock at a price that’s up to 10 points worse than your request.
But this ‘slippage’ provision is questionable in a few ways. If I were your broker, and you told me to buy you an iPhone at $1000, but you also tell me “it’s fine if it’s plus or minus $10 (slippage)”, then doesn’t this mean you’re fine to pay $1010? If so, why don’t I just take $1010 from you, give you the iPhone which I found for $1000, then pocket your $10 for myself? By stating the slippage, isn’t that just giving the broker the freedom to give you a worse price? Yet more trivia: if a person uses the One-Click Buy/Sell Terminal buttons in MT4 or MT5, what’s the slippage setting? Hmm, interesting. The topic of trusting brokers brings us to the next section on hidden levels.
Hidden levels
You might be wondering about Pending Limit Orders being a great order type. This order type says: “buy at my price or cheaper”. They are in fact a great tool; possibly the one that we should use all the time instead of Market Orders. You state an actual price, and by definition it enforces the broker to only buy your stock at that price or better.
But in the previous section, we said that Market Orders are the most relevant, without mentioning Pending Limit orders. Why?
It’s because these days, we no longer sit by the phone calling up our broker to give them instructions. In practice, we now use platforms like MT4 and MT5 that can execute an order immediately on a button click, and we have robots that can help us to instantly buy once it sees the price that we want. This means that if you’re running a trading robot, you can replace a ‘Pending Limit Order’ with an instruction inside your own trading robot to ‘watch the chart until the price goes down then immediately place a Market Order’. And that’s how you’ll usually develop a robot.
In fact, you’ll find that a large number of traders in practice will prefer not to set pending orders because doing so might provide competitive information about your intentions to a broker. Imagine if someone knows all your intentions – exactly what prices you’re waiting to buy at, exactly what price you’d Stop Loss at, and so on. Then it would be easy to create a winning strategy against you. Yet, with a robot, you don’t need to set Stop Losses, nor let anyone know your intended entry and exit levels. Only your robot running on your computer knows, and the only information that others see is you suddenly opening or closing an order. Your actual overall aggregate entry and exit strategy could be very complex, and it’s calculated privately in your robot, not announced as pending levels.
Bonus easier order management
On a more technical note, sticking to Market Orders in robots is not only believed to help hide and protect trading intensions as explained in the previous section, but for robot developers it’s also much easier to grow complex algorithms when not using pending order types. For example, a robot can have an infinitely complex way to assess entry and exit, and execute the action at the very moment necessary. But if instead we have to pend an order with the broker, the robot will now need to continuously monitor whether or not this ticket has been converted into a live floating order. Then, it will need to adapt in order to begin management for this ticket. In MT5 it’s even worse, because pending order ticket numbers change once they become a live order. In each of these cases, although doable, the extra tracking in code is an overhead.
Another drawback of using pending orders is the request quota that many brokers have. There’s usually a quota of instructions you can send to a broker per day. This means that if a robot is constantly modifying a pending order or deleting them at a high frequency, you might eventually get a blocking message from the broker saying that you’ve already reached your limit of order requests for the day. Or, you might experience lag with each order modification. Whereas, if the robot could make its calculations for entry internally, and only execute a Market Order at the moment confirmed, then the robot would work much faster.
There are quite a lot of other very contextual examples (e.g. in hedgers or grid strategies) where at MQL4Solutions we’ve noticed that the strategy is most scalable in complexity and flexibility when a robot sticks to using Market Orders and keeps any decisions or virtual levels within the robot’s brain and not set anything at the broker side as a real pending order type. But of course, these things are contextual and there are still situations where a pending order is very relevant, and that’s fine.
Summary
As algorithmic trading developers, a Market Order is arguably the most relevant order type to know. Combined with the market price integrity check, a spread-size check, and perhaps a slippage parameter, this order type is good enough to replace any pending order types, especially if you have your own robot monkey watching the chart for you 24/7, ready to execute at the moment that matters.
In our feature where we explore the delicate situation of a 1-cent scalp, knowing order types and how to protect expected open prices will come in very handy. That’s why this article is here to cover the basics.