Tutorial on Basic Concepts of Mql-Syntax

Syntax

Have any programming experience? Handled any language derived from C? If the answer is yes, then handling Mql is a piece of cake for you.
But non-programmers have to be little bit more cautious.

MQL programming tutorial by Wetalktrade-syntax

MQL programming tutorial by Wetalktrade-syntax

In MQL, every statement ends in a semicolon and is called an expression. An expression can span multiple lines, and there must be a semicolon at the end.

extern double StopLoss = 15.0; // single line expression

Or this multi-line expression:

if (FastMACurrent > SlowMACurrent)
OpenBuy=true; // multi line expression

If you are new to programming, you will need to make sure you are placing the semicolon at the end of every statement. To not do so is a common newbie mistake.

The Exception To The Semicolon Rule: The Compound Operator

A compound operator is lines of code containing multiple expressions within braces {}. Compound operators can include control operators (if, switch), cycle operators (for, while) and function declarations. Below is an example of a control operator:

MQL programming tutorial by Wetalktrade-operator

MQL programming tutorial by Wetalktrade-operator

if(Bars<100)
{ Print(“Bars less than 100”);
return(0); }

Notice that you are not placing a semicolon after the initial if operator. You don’t have to put a semicolon after the closing brace either. There is a semicolon after the Print() function. That is because there can be one or multiple expressions inside the braces, and each expression must end with a semicolon.