Operations With Variables
In this tutorial I will explain how to use basic MQL4 programming techniques with variables such integers, doubles, strings, and others. We also touch on simple operations: addition, subtraction, multiplication, and division. Finally, we learn how to concatenate strings.All illustrations are supported with working examples using the Alert() statement.
If even after the video tutorial you are still curious, then you can always find additional information on the official MQL4 website.
MQL4 Programming Video
This video is short, sharp and to the point. We learn by doing and there’s lots of practice. Also, you can write your own test code as much as you want! In fact, I encourage you to do so, because there is no better way to learn MQL4 Programming than by trying!
As always, the code for this tutorial is located underneath the video. Feel free to post any questions and / or feedback in the comments section at the end of the post. I am interested to hear from you!
Code For This Tutorial
Tutorial3.mq4:
//+------------------------------------------------------------------+
//| Tutorial3.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;
double var1 = 2.5;
double var2 = 4;
double result = var1 / var2;
string greeting = "Hello";
string space = " ";
string name = "Bob";
string message;
C = A + B;
message = "Value of A is: " + string(A);
Alert(message);
//Alert(C);
//Alert(result);
//Alert(message);
}