## 3. Variables and Their Types

Let’s go over the basic programming knowledge we need for Meta Editor. As a tutorial, practice is the base of this site. But this page is a preparation before that step.

This is going to be an abstract explanation of programming so if you have experienced programming with other kinds of language, you can skip this part.

## 0. Typical Things About Programming

These are things you absolutely must know about programming:

• Put a “;” (semi-colon) at the end of each sentence (order).
• When using a string in the program, enclose it with a " (double-quotation mark) or ' (single-quotation mark).

These are the least things you should remember. I ’m sure you’ll get used to this as we go on.

## 1. What is a Variable?

Have you ever heard of the word “variable”?

You must have heard it in your mathematic lectures before. Mathematically it means “a number that is unknown or that can’t be defined as a unique number”.
For example, in “x2+2x+1=0” x is used as a variable. (x=-1 is supposed to be unknown within the sentence.)

The “variable” we use in programming is a little different from it. It’s something like a label to call up an arbitrary data.

For those who have some experience with programming, the concept would probably be familiar. But for those who have not, this is a little complicated idea. So let’s take a look at some examples.

1. int x = 0; // "x" will be set to 0.
2. x = x + 1; // "x+1" (which means 0+1=1) will be set as "x".
3. Print(x); // the value of "x" will be printed.

In the example above, we labeled ”0” as “variable x”. Thus, "x=0" means “define x as 0”. I will explain about “int” next.

1. string message = 'Hello, ';
2. message = message . 'world!';
3. Print(message); // "Hello, world!" will be displayed

In this way, you can label letters as variables and control them.

## 2. Data Types

Variables can indicate numbers and letters. However you need to clearly specify what kind of data is contained.

This is a big difference from script series language such as PHP so those who have experience in programming should be careful as well.

There are many kinds of data types. These are the ones you should at least know.

• Integer
Just as written it is integers. Enter “int” in front of the variable.
• Floating Point
This is numbers that include decimals. Enter “double” in front of the variable.
• Date
It expresses Unix Time, the seconds passed since (1/1/1970). Enter “date” in front of the variable.
• String
It indicates strings of letters. You can contain both 1 byte letters and 2 bit letters. Enter “string” in front of the variable.
These are the examples.
1. int example1 = 12;
2. double example2 = 3.1415;
3. date example3 = 1214850744;
4. string example4 = 'Types of variables are defined like these.';

When you make a program by using Meta Trader be careful not to forget to define the types of variables.