MQL4 Return Operator

Overview

The return operator terminates the execution of the current function and returns control to the calling program. The result of an expression calculation is returned to the calling function. The expression can include an assignment operator.

Syntax and Usage

  • **With Value:**
  •   return(expression);
      
    The expression's calculated value is returned.

  • **Without Value (for void functions):**
  •   void SomeFunction() {
        // ...
        return;
      }
      
    This operator can be omitted in void functions, as the function's closing brace implicitly executes return; without an expression.

    Returnable Types

  • Simple types
  • Simple structures
  • Object pointers
  • Non-Returnable Types

  • Arrays
  • Class objects
  • Variables of compound structure type
  • Related Concepts

  • [Expression Operator](/basis/operators/expression)
  • [Conditional Operator if-else](/basis/operators/if)
  • [Function](/basis/function)
  • [Void Type](/basis/types/void)
  • [Initialization of Variables](/basis/variables/initialization)
  • [Visibility Scope and Lifetime of Variables](/basis/variables/variable_scope)
  • [Creating and Deleting Objects](/basis/variables/object_live)