MQL4 Operators

Overview

  • Program bodies consist of sequences of operators.
  • Operators are separated by semicolons (;).
  • Operators describe algorithmic operations.
  • Operators can span multiple lines.
  • Multiple operators can exist on a single line.
  • Control flow operators (if, if-else, switch, while, for) can be nested.
  • Operator Types

  • **Compound Operator {}**: Groups one or more operators of any type.
  • **Expression Operator ;**: Any expression terminated by a semicolon.
  • **return Operator**: Terminates the current function and returns control to the caller.
  • **if-else Conditional Operator**: Used for making choices.
  • **?: Ternary Conditional Operator**: A simplified if-else analog.
  • **switch Selection Operator**: Transfers control to an operator corresponding to an expression's value.
  • **while Loop Operator**: Executes an operator repeatedly as long as a checked expression remains true. The expression is checked before each iteration.
  • **for Loop Operator**: Executes an operator repeatedly. The expression is checked before each iteration.
  • **do-while Loop Operator**: Executes an operator repeatedly. The loop body executes at least once. The end condition is checked after each loop.
  • **break Operator**: Terminates the execution of the nearest enclosing switch, while, do-while, or for operator.
  • **continue Operator**: Passes control to the beginning of the nearest enclosing while, do-while, or for loop operator.
  • **new Operator**: Creates an object of the appropriate size and returns a descriptor.
  • **delete Operator**: Deletes an object created by the new operator.
  • Related Concepts

  • [Initialization of Variables](/basis/variables/initialization)
  • [Visibility Scope and Lifetime of Variables](/basis/variables/variable_scope)
  • [Creating and Deleting Objects](/basis/variables/object_live)
  • [Precedence Rules](/basis/operations/rules)