Today we are going to talk about a fundamental cornerstone of any programming language – functions.
To execute a market order in the past tutorial we used the OrderSend() function. Well, MQL4 has many more other functions which we will be using throughout this course. Therefore, it is important to understand what functions are and how they work.
In this tutorial I will even show you how to create functions of your own. After you create your first function everything will fall into place and the next couple of tutorials in this course will seem like a piece of cake!
Enrol in the full course here: https://www.forexboat.com/learn-mql4
//+------------------------------------------------------------------+
//| Tutorial16.mq4 |
//| Copyright 2014, ForexBoat |
//| http://www.forexboat.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, ForexBoat"
#property link "http://www.forexboat.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
int A = 10;
int B = 5;
int C = MyAddition(A, B);
Alert("C = ", C);
}
int MyAddition(int val1, int val2)
{
return(val1 + val2);
}