0% found this document useful (0 votes)
17 views3 pages

Understanding Order Types

The document explains different order types in trading, including Limit and Stop orders, detailing how they function and when they are executed. It also provides coding examples for placing pending orders and discusses the transition from pending to market orders, highlighting the potential for slippage during volatile market conditions. The importance of using a broker that allows access to the Order Book for better pricing is emphasized.

Uploaded by

Wafa Noor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Understanding Order Types

The document explains different order types in trading, including Limit and Stop orders, detailing how they function and when they are executed. It also provides coding examples for placing pending orders and discusses the transition from pending to market orders, highlighting the potential for slippage during volatile market conditions. The importance of using a broker that allows access to the Order Book for better pricing is emphasized.

Uploaded by

Wafa Noor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Black Algo Technologies

Understanding Order Types


So far, we have only looked at robots that fired market orders – an order to buy or sell at the best
price available. We now look at two other order types: Limit and Stops.

Limit Orders

BuyLimit is a pending order to buy assets for a security at a price lower than the current one. The
order will be executed if the Ask price reaches or falls below the price set in the pending order.

SellLimit is a pending order to sell assets for a security at a price higher than the current one. The
order will be executed if the Bid price reaches or rises above the price set in the pending order.

Stop Orders

BuyStop is a pending order to buy assets for a security at a price higher than the current one. The
order will be executed if the Ask price reaches or rises above the price set in the pending order.

SellStop is a pending order to sell assets for a security at a price lower than the current one. The
order will be executed if the Bid price reaches or falls below the price set in the pending order.

[Link]
Black Algo Technologies

Coding for Pending Orders

Here are the OrderSend code for pending orders (modified from BelindaSizing). Let’s assume that I am
place orders 100 points above or below current bid and ask prices.

Buy Limit

Ticket = OrderSend(Symbol(), OP_BUYLIMIT, Lots, Ask-100, Slippage, StopLossLevel,


TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);

Sell Limit

Ticket = OrderSend(Symbol(), OP_SELLLIMIT, Lots, Bid+100, Slippage, StopLossLevel,


TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);

Buy Stop

Ticket = OrderSend(Symbol(), OP_BUYSTOP, Lots, Ask+100, Slippage, StopLossLevel,


TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);

Sell Limit

Ticket = OrderSend(Symbol(), OP_SELLSTOP, Lots, Bid-100, Slippage, StopLossLevel,


TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);

Note: TakeProfitLevel and StopLossLevel are price levels, not pips. Do make sure they reflect the correct
price levels. Eg. For a Buy Limit order at 1.2345 with 60 pips take profit and 30 pips stop loss, we
should input a TakeProfitLevel of 1.2405 and a StopLossLevel of 1.2315.

Touch and Market – From Pending to Market Orders

When the price levels of our pending orders are hit, they become market orders.

• Pending orders BuyLimit and BuyStop are modified to market ones, if the last known Ask price
reaches the requested pending order price.
• Pending orders SellLimit and SellStop are modified to market ones, if the last known Bid price
reaches the requested pending order price.

This has two implications for us:

1) We are always buying at the Ask price and selling at the Bid price. In order to buy at the Bid
and sell at the Ask price, we need a broker and platform that allows us to view and place orders
on the Order Book/Level 2 Ladder/Depth of Market (DOM). More on this in future lectures.

[Link]
Black Algo Technologies

2) Slippages may occur. Slippages occurs when your order gets filled at a price worse than
specified. In times of high volatility, market price may jump violently and break through your
pending order’s price. This may cause you to fill at a worse price.

From the chart above, we can see that the big downwards spike caused us to fill our order at
a worse price. When the price breaks the Sell Stop level, the order turns into a market order.
However, there are no one willing to fill our order at the Sell Stop level. In order to sell, someone
else must buy from us. In this case, the price is racing downwards. It is natural that no one
wants to buy while price is free-falling.

Hence, we fill our order at a lower (worse) price. The difference between our Sell Stop price
and the price where we filled our order is our slippage.

[Link]

You might also like