Examples: MQL4 Language for Newbies. Introduction

 

New article MQL4 Language for Newbies. Introduction has been published:

This sequence of articles is intended for traders, who know nothing about programming, but have a desire to learn MQL4 language as quick as possible with minimal time and effort inputs. If you are afraid of such phrases as "object orientation" or "three dimensional arrays", this article is what you need. The lessons are designed for the maximally quick result. Moreover, the information is delivered in a comprehensible manner. We shall not go too deep into the theory, but you will gain the practical benefit already from the first lesson.

Author: Antoniuk Oleg

 
Great, really a good start for new beginners like me.
 

hello :

I am starting to learn MQL4 . I think you are doing so well to explain from the begining . Hope you can answer next , please :

I did try to add a number type to a string type as in the example :

int a = 50;

int b = 100;

string str1 = " a + b";

str1 += a + b;

MessageBox(str1 , "a+b=?");

However , every time I receive a error message : " += " - both operands are to be numeric .

Can you help me ? please

thank you

 
Great work! Thank you!
 
This is just what I was wanting - thank you.

However, there are a number of errors in your article,  some very significant and some not so much.  (I am not referring to the strange use of English but to the actual meat of the article.) Would you like me to point them out?

Malcolm
 
  int a = 50; 
int b = 100; 
string str1 = "a + b =";   
str1 = str1 + (a + b); // now str1 = "a + b = 150"   
// now use the variable str1 as 
// a first parameter
MessageBox(str1, "a + b = ?");

written like this.. it works
 
If you are new to MQL, you may want to check this tool Strategy Builder - It's a visual environment to create EA - no need to learn mql or code - this tool does it for you
 

Not great, same as all the other tutorials.

 
// of course the conditionsn should be written in MQL4
if( I have enough time )   
  {  
    // here we place any actions, directions in MQL4
    will read this book; 
  }
// if the first condition is not fulfilled, 
// the second is fulfilled
else   
  {
    read a magazine;  // code
  }

Now you should understand the syntax of conditions. Let’s view conditions, fully written in MQL4 language:

Your tutorial is well written but fails where almost all the mql4 documentation I have read fails, on the syntax description. At no point did you describe or mention why braces should be used, what they are for and what will happen if they are put in the wrong place, the same goes for parenthisis, this is probably on of the biggest problem people new to programming face when they try to learn mql4 and it seems none of the tutorial writers have any comprehension of this, you did go some way to explaining the use of parenthesis but even that was a hazy kind of by the way explanation, if you really want to help newbies learn mql4, start by writing a tutorial properly explaining the syntax, especially the use of braces, parenthesis and semi colons.

 

Hello everyone.

Excuse my English.

I have seven years doing trading and only half month learning MQL4. I have some questions.

In this chart suppose:

    

Highs
Price
High[0]
1.2676
High[1]1.2677
High[2]1.2676
High[3]1.2675
High[4]1.2675
 High[5] 1.2680


About the example 2 in examples.mq4:

double maxAverage=0.0;
   double minAverage=0.0;
   
   for(a=0;a<Bars;a++)
   {
      maxAverage+=High[a];
      minAverage+=Low[a];         
   }
   
   maxAverage/=Bars+1;
   minAverage/=Bars+1;
   
   MessageBox("maxAverage="+maxAverage+" minAverage="+minAverage,"max and min averages");

Questions:

1) In the line

for(a=0;a<Bars;a++)

I understand that Bars = 6 and "a" takes the values, ¿is this correct?

a =
0
a =
0+1
 a =
1+1
 a =
2+1
 a =
3+1
 a =
4+1


2) Is maxAverage+=High[a] calculated as follows?

a =
High
maxAverage = maxAverage + High[a]
0
1.2676
1.2676 = 0 + 1.2676
1
1.26772.5353 = 1.2676 + 1.2677
2
1.26763.8029 = 2.5353 + 1.2676
3
1.2675
5.0704 = 3.8029 + 1.2675
4
1.2675
6.3379 = 5.0704 + 1.2675
5
1.26807.6059 = 6.3379 + 1.2680


3) How to find the average maximal price with this line?

maxAverage/=Bars+1;

maxAverage = maxAverage /(Bars+1)

maxAverage = 7.6059 / (6+1) ? => wrong answer.

or

maxAverage = (7.6059 / 6) + 1 => wrong answer again.

Thank you for your help.

 

Hello there,

I'm pretty new and I somehow don't seem to extract all knowledge there is from your text

But you don't walk me through as you advertise. I don't seem to get it right.

For example If I'd like to do something like this:

void OnStart();
{
double AveragePrice = 0.0;
int a = 0;
for(int a = 0; a < Bars; a++)
    AveragePrice += High[a];
MessageBox("AveragePrice= " + AveragePrice, "Average Price");
return(0);
}

So I want the script to give the average high price to me in a MessageBox, that should not be too difficult, but the problem keeps finding mistakes if I compile.

It says there is something wrong with the opening brace "{". What seems to be the problem here? It's really frustrating.

And maybe you can write everything down to a "t" so that real newbies can see where the mistakes are, that would be terrific.