A trading order is an instruction you send to your broker in order to buy, sell, short or cover a security. There are different types of orders, but they all share some common characteristics like the security symbol or ID and the number of shares to enter or exit. An order can be a buy order or a sell order, the former is used to buy or cover a security while the latter is used to sell or short a security. If you want to take a long position on a security, you have to use a buy order to enter the trade and a sell order to exit the trade. But if you want to be short on a security, you have to do the opposite, that is, send a sell order to short the security and then a buy order whenever you want to cover your position. Some brokers like "interactive brokers" offers over 50 order types, many of them are algorithms and conditional orders that execute basic orders when triggered. Here is a list of basic order types: Market Order: This order is executed at the best price available (Generally a buy order is executed at the ask price and the sell order at the bid price). Limit Order: A limit order is an order to buy or sell an asset at a specific price. In the QuantShare backtesting engine, you can define a limit order as shown in the picture below. The order is executed only if the price you specify in the limit order is between the high and low price of a security, otherwise the order won't be filled and the high-low boundaries will be checked during the next trading bar. You can of course specify the number of days or bars to keep the trading order. This is done using the functions: BuyPrice, SellPrice, ShortPrice and CoverPrice. If after the specified number of bars the order is not filled yet, it will be automatically transformed into a Market-On-Open order. (The limit order is canceled and a MOO order is created). Market-On-Open (MOO): This is the default market order used by the QuantShare backtester. It is a market order that is submitted at the market's open. The filled price is the open price of the security at the day the order was submitted. Market-On-Close (MOC): This is also a market order; this order is automatically submitted at the market's close. Stop Order: This is an order that instructs the broker to submit a buy or sell order if the user-defined stop trigger price is reached. This order is used by the different implementations of stops (Stop loss, Trailing stop, Profit stop and N-Bar stop). If a stop limit is reached then the QuantShare backtester transforms the Stop order into a Market order or a Market-On-Open order. Depending on your trading system settings, the simulator will submit a market order and you will be filled at the trigger price or a MOO order is submitted and you will be filled at the next bar open price. In backtesting, setting the simulator to take a market order (you will be filled at the stop trigger price) after a stop price is reached is not a good idea because generally in a real trading environment your order will be filled at a much worse price that the trigger price. As an example imagine a stock that you own is hit by a bad news, and let us say that your trigger exit price is 9 dollars. If the stock price moves from 10 dollars to 8 dollars (gap), the backtester will exit the position at 9 dollars. But in reality the real exit price is near 8 dollars.
|