Lesson 4 - MQL4 Operations & Expressions - page 2

 

Assignment addition!

newdigital:
It is arithmetical operations but it is logic.

In arithmetic if

A + B so it should be C already.

It should not be the same A (the same value).

Because if we are increasing A on B assigning the result to A so

A will be increasing on B all the time. Every second A will be increasing on B without any stopping. It means A plus B is equal A (the same A?) so plus B once again (because of A plus B) is equal A (an other A) which should be added to B and so on.

May be during the coding everything will be clear.

I'll give you an example and I hope it will make it clearer:

You have in your pocket 10$ ok?

int your_pocket = 10;

Then I gave you 5$ ok?

int i_gave = 5;

You putted the 5$ which I gave to you in your pocket, How much in your pocket now and how to collect them?

your_pocket(now) = your_pocket(before I gave you the 5$) + i_gave (5$ which I gave them to you)

your_pcoket=your_pocket+i_gave; //which is 15$

You can write the above expression like this:

your_pocket+=i_gave; //which is 15$

So, the purpose of this operator is to increase your_pocket with the amount i_gave you and assign them again to your_pocket(or update your_pocket or put them back to your_pocket).

Is it clearer now?

Now, I want my 5$ back

newdigital:
But I have a question.

In Relational operators A == Bi;

It means true if A equal B else false.

Is it necessary to have i after B?

Where did you come with the i? was it in the lesson? If yes it was a keyboard mistake and I'll update it.

A == B; means:

You asking MQL4 is A equal to B and MQL4 has to answer you with True or False (yes or no).

 

I was looking for a place to learn Meta trader 4 language. Finally........................thanks a lot................thanks again.

 

You're Welcome!

razib2006:
I was looking for a place to learn Meta trader 4 language. Finally........................thanks a lot................thanks again.

You're Welcome!

I hope you enjoy them

 

Hi, I am new to this forum and am looking forward to reading your Metatrader lessons. However, I cant find lessons 1 and 2 (I am at the moment reading lesson 3)

Thanks

Mike

 
mike:
Hi, I am new to this forum and am looking forward to reading your Metatrader lessons. However, I cant find lessons 1 and 2 (I am at the moment reading lesson 3)

Thanks

Mike

Mike,

To view all the lessons' threads, choose a long period (EX: Last year) in display options.

 

It is arithmetical operations but it is logic.

In arithmetic if

A + B so it should be C already.

It should not be the same A (the same value).

Because if we are increasing A on B assigning the result to A so

A will be increasing on B all the time. Every second A will be increasing on B without any stopping. It means A plus B is equal A (the same A?) so plus B once again (because of A plus B) is equal A (an other A) which should be added to B and so on.

May be during the coding everything will be clear.

This is often very confusing for first time programmers. Note that the "=" and the "==" are used very differently. "=" is called the assignment operator because it causes the expression on the right hand side to be assigned to the variable on the left hand side. There is no infinite loop as you suggest.

The expression A=A+B; means:

take the current value of the variable A and add it to the current value of the variable B. Then place the result of the addition into variable A. So, after the expression is executed, the value of variable A will change.

For example, if A equaled 2 and B equaled 3 than after executing A=A+B (or the equivalent A+=B) A would have the value 5 assigned to it.

But I have a question.

In Relational operators A == Bi;

It means true if A equal B else false.

Is it necessary to have i after B?

I think you may have mistakent the semi-colon for an "i". You are correct in your definition of this logical expression except for the inclusion of the extra character "i" the relation A==B is true if A equals B and false otherwise.

I hope this helps.

 

Hi coders !!!

I am studying from very begin. I am testing every operator because of training Could you explain how "+-" operator works ? I tryed but it makes error in compiling. Could you give me a simple, sample code with that operator.

Thnx !

passass

 

Expression

Hi coders...

This expression is complex (MT4) for me. It could help me?

(b-d)<=((d-c)/5))

(b-a)<=((a-c)/5))

(d-c)<=((b-d)/5))

(a-c)<=((b-a)/5))

Thanks,

 

Help

Hi, Coders..

It would like to know as it would be the represented number below in the MT4.

0,000072

Thanks,

Ok!!! No have problems!!!!

 

hello there guru,

thanx for your tutorials. i'm still grasping the concept of mql programming.

but i'm not so sure about the logical operations in page 6.

shouldn't it be that:

OR eg. A = B || C

--------------------

- A is true only if either B or C or both are true.

- A is false only if both B and C are false

EXOR eg. A = B ^ C

---------------------

- A is true if and only if either one are true

- A is false if both B and C are true

- A is false if both B and C are false

And aren't bitwise operation works like a mask? thus it works on bytes (i think)?

to say that it returns 0 makes it sound like a logic operation, while it's more than that.

for the expression A = B^C

if.. B is 10101010

if.. C is 01010101

so A is 11111111

other example

if.. B is 10101010

if.. C is 11111111

so A is 01010101

haven't coded for a long time... correct me if i'm wrong.

Reason: