Questions from Beginners MQL5 MT5 MetaTrader 5 - page 444

 
Karputov Vladimir:

What's wrong with that? :

I don't quite understand... here we assign a value to a variable, but we don't generate a variable name, or am I misunderstanding something?
 
-Aleks-:
I don't quite understand... here we assign a value to a variable, but we don't generate a variable name, or am I misunderstanding something?

А... I got it. I'll write an algorithm for working with a global variable...

The algorithm is as follows:

  • start EA: if a variable does not exist, it is created and the calculated value is assigned to it; if a variable exists, we get its value and write it into a variable;
  • deinitialize EA: if the variable does not exist, it is created and the calculated value is assigned to it; if the variable exists, the new calculated value is assigned to it;

Here:

Files:
 
Karputov Vladimir:

А... I got it. I'll write an algorithm for working with a global variable...

The algorithm is as follows:

  • start EA: if a variable does not exist, it is created and the calculated value is assigned to it; if a variable exists, we get its value and write it into a variable;
  • deinitialize EA: if the variable does not exist, it is created and the calculated value is assigned to it; if the variable exists, the new calculated value is assigned to it;

Here:

Thank you! But I need it for MT4...
 
-Aleks-:
Thank you! But I need it for MT4

Well, there's one magic manoeuvre here:

Copy *.mq5 file to MQL4 Expert Advisor folder and change its extension to *.mq4 (although it's high time to switch to MQL5).

 
Karputov Vladimir:

Well, there's a magic trick here:

The *.mq5 file should be copied into MQL4 Expert Advisors folder and changed to *.mq4 (although it's high time we switched to MQL5).

It worked, but it's a bit too cool for me - complicated code with incomprehensible operators - I'm not mature enough yet.

So, which variable passes the value of the global variable and how do I get the value of the global variable and assign it to the internal variable?

 
-Aleks-:

It worked, but it's too cool for me - complicated code with incomprehensible operators - I'm not mature enough yet.

So which variable passes the value of the global variable and how do I get the value of the global variable and assign it to the internal variable?

It's all there. And calculating a new value and getting the old one, and getting the current value. Well, do not shoot a video with explanations :)
 
Karputov Vladimir:
It's all there. And calculating the new value and getting the old value and getting the current value. Well, you can't make a video with explanations :)
This is good. I probably need to translate the comments - it's the first time I've heard such words in English :)
 
-Aleks-:
That's good. Probably need to translate the comments - it's the first time I've heard such words in English :)
I write comments in English on purpose - I develop my language skills, so there will be no comments in Russian. Sorry.
 
Karputov Vladimir:
I am writing comments in English on purpose - I am developing my language skills, so there will be no comments in Russian. Sorry.

I'm not offended - the boss is the boss!

Well, just hope that I can get some sensible answers to new questions about the code...

 

Good afternoon,

I am using the standard library,

Several indicators are generating trading signals

have defined thresholds(ThresholdOpen and ThresholdClose)

How are the trading signals compared?

For example:

-the buy signal of one indicator, it is m_pattern_0 and it is equal to 50,

-but the second indicator tells us to sell, and its m_pattern_1 is 50

but we have not specified anywhere that m_pattern_0 and m_pattern_1 must be compared,

how does this work?

Reason: