Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 829

 

There is a question of this format: There is this code

int P=3;

if(P==5){then it is necessary to get into the library and calculate something}

In this situation P=3, i.e. the condition is false. The question is, will the compiler get into the library and idly run the code or will the compiler read the code in the current file? I'll explain why I was asking that. Well, look, suppose we write the following format condition

int Y=4;

if(Y==4){do something} else{do something else}. In this situation we get the following picture Y==4, the first we can say, the priority operator was executed, but the else{do something else} block will also be checked and computed (just computed and always), but not executed, because the priority is an expression if(Y==4). In other words, regardless of the truth result, the machine does all calculations, i.e. it spends power on calculations regardless of whether the secondary operator is executed or not. If I use large programs and libraries, and the compiler will every time digging the library code, it will eventually slow down the program. How effective will be the use of libraries in this case, should I use the mql4 code itself as concise as possible to make the robot performance high? Who has any thoughts on this subject?

 
Pavel Soin:

Hello.

Let's say I have 2 indicators, the first has 4 buffers, the second has 2. I put them on a chart and open data window (CTRL+D). The list contains 6 buffers from 0 to 5. How can I read the value of buffer 5, say, from this list in MQL? It is not convenient to use iCustom by the required indicator. It is more convenient to use this list. I know that they do that, but how?

Can someone help me?

 
Seric29:

There is a question of this format: There is this code

int P=3;

if(P==5){then it is necessary to get into the library and calculate something}

In this situation P=3, i.e. the condition is false and the question is, will the compiler get into the library and idly execute the code or will the compiler read the code in the current file? I'll explain why I was asking that. Well, look, suppose we write the following format condition

int Y=4;

if(Y==4){do something} else{do something else}. In this situation we get the following picture Y==4, the first we can say, the priority operator was executed, but the else{do something else} block will also be checked and computed (just computed and always), but not executed, because the priority is an expression if(Y==4). In other words, regardless of the truth result, the machine does all calculations, i.e. it spends power on calculations regardless of whether the secondary operator is executed or not. If I use large programs and libraries, and the compiler will every time digging the library code, it will eventually slow down the program. How effective will be the use of libraries in this case, should I use the mql4 code itself as concise as possible to make the robot performance high? Who has any thoughts on this subject?

The built-in debugger of MetaEditor answers these questions very well. You should write a script with similar conditions and run it step by step in the debugger. You will see that the program will not enter the place where it has nothing to do. Moreover, such a condition

int P = 3, Y = 4;
if(P == 5 && Y == 4)

After checking that P != 3 nothing will be checked further.

 
Good afternoon. Can you tell me what to do to keep all the graphic elements on the chart at the weekend?
 
Lomonosov1991:
Good afternoon. Can you tell me what to do to keep all the graphic elements on the chart at the weekend?
Do not delete them
 
Alexey Viktorov:

The built-in debugger in MetaEditor answers these questions very well. Write a script with similar conditions and run it step by step in the debugger. You will see how the program does not enter the place where it has nothing to do. Moreover, this condition

After checking that P != 3 nothing will be checked further.

Here is an example

int pp=8;if(pp==8){pp=3;}else{pp=340000000000000000000000000000;}

pp=8 in this case is 8, but the compiler swears at the big number, which I want to put into a variable, but I won't put this number into a variable because pp=8 is correct, but for some reason the compiler starts to dig what I wrote and checks if it can be, so we conclude that it is the compiler that checks and counts, well, this is certainly a rough error, we could make less serious error, but the compiler will still check if it can be or not. I don't mean to write that kind of stuff in it, but the compiler will check what it is supposed to do, but it won't do it and it will count. I tried to work with the MQL4 debugger I read the instructions herehttps://www.metatrader5.com/ru/metaeditor/help/development/debug but I didn't even see an active tab "check against history" although the instructions suggest it should be active.

 
Seric29:

Here's an example

int pp=8;if(pp==8){pp=3;}else{pp=340000000000000000000000000000;}

pp=8 in this case is 8, but the compiler swears at the big number, which I want to stick in a variable, but I won't stick this number in a variable because pp=8 is correct, but for some reason the compiler starts to dig what I wrote and checks if it can be, so we conclude that it is the compiler that checks and counts, well, this is certainly a crude error, we could make less serious error, but the compiler will still check if it can be or not. I don't mean to write that kind of stuff in it, but the compiler will check what it is supposed to do, but it won't do it and it will count. I tried to work with the MQL4 debugger I read the instructions from herehttps://www.metatrader5.com/ru/metaeditor/help/development/debug but the "check against history" tab is not even active, although the instructions suggest it should be. I tried to check with real data but in this case the variable values are not shown, they are all empty, I just wondered how it could be that way.

The compiler checks for valid values at compile time, but not at runtime. Read up on variable types and within what ranges the values of those variables are allowed. If the compiler didn't check these ranges, you might lose values at the moment of code execution and get wrong results of calculations. So this behavior is good for the programmer. The compiler will always warn us about the possible loss of accuracy.

And the MT4 debugger doesn't work on historical data. It is the prerogative of MT5 tester. But there is no sense to debug scripts on history anyway, and you can observe what I suggest in the MT4 tester. You just need to set a breakpoint at the beginning of the code and then observe the sequence of execution and values of variables step by step.

 
Do you think it's OK to discuss pieces of decompiled code?
They should at least rename the variables. It's not so brazen...
 
Artyom Trishkin:
Do you think it's OK to discuss pieces of decompiled code?

They should at least rename the variables. Otherwise, it's too brazen...

This EA is available online in MQL4 format. Trio Dancer. I'm just remaking it for me.

 
Lomonosov1991:

This advisor is available online. Trio Dancer. I'm just modifying it for me.

So what? There are places where they buy and sell stolen goods.
This forum is not in that category.
It was hacked (stolen from the author) some time ago and now you are making it for yourself. Please do not do it on this site. We have ethics here.