## 5. Making orders with MetaTrader

From here on, many functions necessary for programming in MetaTrader will be presented to you.
We recommend those of you with programming experience to read from this section onwards!

## 1. What is a Function?

What the heck is a function? Some of you may remember hearing that term in your algebra class long time ago.

But here in the programming world, "function" has a different meaning from that of algebra.

Simply put, A function in programming carries out an order. They are either built-in or made from scratch, but we will worry about developing personal functions later.

## 2. Placing an Order

In MetaTrader (MetaEditor), OrderSend() sends out an order.

Please recalled the following line from a previous chapter.

What are those letters inside the parentheses after OrderSend all about？
They are usually called "arguments", and serve as parameters for the function.

・・・Sounds like a crazy talk?

Then please think of it this way.
If only OrderSend() is typed in, then which currency should the computer buy?
Or maybe the computer shouldn't even be buying (long), but instead be selling (short).
The computer cannot do anything without knowing how much to buy/sell either.

The letters inside the parentheses deliver such important information to the computer.
They are processed inside the function (this is called "passing the arguments"), thus enabling the computer to act as you want it to.

Let's look at the meaning of each parameters from the above example. The number refers to the order of the parameters.

1. Symbol Symbol() - data type: string
Represents "the currency pair to be traded".
Represents the entry of market through "Buy (long)".
To "sell (short)", type in "OP_SELL".
3. Volume Lots - data type: double
Sets the "quantity of the traded currency". In the example above, variable Lots needs to be defined already.
For instance, if 0.1 is input, then 10,000 currency units are traded.
4. Price Ask - data type: double
Both Ask and "Bid" are special variables. They represent the current selling price and buying price, respectively.
5. Slippage 3 - data type: integer
"Slippage" sets the allowable deviations on the price at which trading can still take place.
This is expressed in units of "pips". This is used as the countermeasure for the time lag caused by the price information reaching the computer.
6. StopLoss NULL - data type: double
NULL represents StopLoss. Type in NULL when it is not specified.
7. TakeProfit NULL - data type: double
The NULL on the seventh parameter represents TakeProfit. Type in NULL when it is not specified.
8. Comment NULL - data type: string
The NULL on the eighth parameter represents Comment. This is used when you want a comment to be displayed upon making the transaction. Type in NULL when it is not specified.
9. Magic 0 - data type: integer
10. Expiration 0 - data type: datetime
11. Arrow_Color 0 - data type: color

The last three parameters (9~11) will not be used here in order to keep the matter relatively simple. For now, just know that such things exist.