## 4. Common Operators

In the previous chapter, we reviewed over the concept of "variables," a concept fundamental not only to MetaEditor but to all kinds of programming. Here, we will discuss "operators," a set of tools necessary to utilize variables.

An "operator" might sound like something difficult to wrap your head around, but in fact it is simply a collective term used in programming for math symbols such as "+" and "÷".

## 1. Algebraic Operators

As its name suggests, algebraic operators are those that represent arithmetic operations.

1. int number = 3 + 4; // [addition]number is 7
2. int number = 3 - 4; // [subtraction]number is -1
3. int number = 3 * 4; // [multiplication]number is 12
4. double number = 3 / 4; // [division]number is 0.75

Note that the data type for the variable number in the 4th line is double.

The following are additional algebraic operators frequently used in programming.
The first operator is "%". "a % b" represents "the remainder of a divided by b". (Algebraically, it is the smallest integer among a (mod b)).
The second operator is not exactly algebraic, but is a period ".". This operator is used to connect two sets of strings.

1. int number = 16 % 3; // number is 1
2. string example = "It is " + "fine today."; // example is "It is fine today."

## 2. Branch

Upon developing, though not limited to, an investment program, a branch almost always comes in.
For example, the "if" in "Take a long position if EURUSD exceeds the maximum value of the past 5 hours" is a branch.

Let's turn the example above into a MetaEditor program.

1. double max=High[iHighest(NULL,PERIOD_H1,MODE_HIGH,5,1)];
2.
3. if(max < High){
5. }

The first line assigns the maximum value of the past 5 hours to variable max.
The third line compares the value of variable max and the current maximum value. If the latter is greater, the 4th line sends out an order.

Although the details of the first and third line may not be comprehensible at the moment, hopefully the concept of branch is.

## 3. Comparison Operators

In the third line in the previous example, the value assigned to variable max and the current maximum value are being compared. An operator that expresses such a relationship is called a "comparison operator".

The following are some of the examples of comparison operators:

1. a > b // a is greater than b
2. a >= b // a is greater or equal to b
3. a < b // a is less than b
4. a <= b // a is lesser or equal to b
5. a == b // a and b are equal
6. a != b // a and b are not equal

These operators tend to be utilized inside () brackets in if statements (branch).