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

 
законопослушный гражданин:

I adjust as follows:

1.I click on the slider once, then the mouse can be moved, the main thing is not to click in other spaces

2.I adjust it by pressing the arrows on the keyboard - faster slower

P.S., on the built-in MT4 strategy tester

Eh, it would be a fairy tale if you could click on a graph and the effect of the hotkeys didn't reset. But it's better than nothing
 

A question has arisen. Does it make sense to declare static variables in the global scope.

In the local one I understand, no visibility outside the function body and saving values of the previous call.

And what could be the point in a global one?

 
Valeriy Yastremskiy:

A question has arisen. Does it make sense to declare static variables in the global scope.

In the local one I understand, no visibility outside the function body and saving values of the previous call.

And what would be the sense in a global one?

Only if it can be changed in different functions

 
MakarFX:

Only if it can change in different functions

I don't get it) The global variable also changes in different functions. The stat.variable in this case is no different from the usual global variable. And the memory is located in the global pool. From the reference:

Variables

There are three memory classes: static, input and extern. These memory class modifiers explicitly tell the compiler that the corresponding variables are allocated in a predefined area of memory, called the global pool.

Sometimes I come across static variables declared in the global scope in the code. I cannot understand the authors' logic.

 
Valeriy Yastremskiy:

I don't get it) Global also changes in different functions. It's no different from a regular global variable in this case. And the memory is located in the global pool. From the reference:

Variables

There are three memory classes: static, input and extern. These memory class modifiers explicitly tell the compiler that the corresponding variables are allocated in a predefined area of memory, called the global pool.

Sometimes I come across static variables declared in the globalscope in thecode. I cannot understand the authors' logic.

Yes, you are right and there is no logic. That's just how the author of the code sees it.

My previous post wasn't thought through.

 

Valeriy Yastremskiy:

I don't understand the logic of the authors.

There is no logic, only schizophrenia. The expression "buttery oil" is such a polite definition of "schizophrenia".

 
MakarFX:

Yes, you're right and there is no logic. It's just how the author of the code sees it.

Alexey Viktorov:

There is no logic, only schizophrenia. The expression "oiled up" is such a polite definition of "schizophrenia".

Thanks, sometimes it's hard to find the author's logic through the code))))

 
MakarFX:
yes

Could you please advise

How to return the starting lot -Lot, (to open the next order), after the execution of this part of the function:

if(GetProfitFromStart()>CountProfit || GetProfitFromStart()<CountLoss*-1)
     {
      if (IsTesting()) 
        {
         CloseOrder(); ObjectSetInteger(0,"lab_Button",OBJPROP_STATE,false);
        }
      else
        {
         CloseOrder();
        }
     }
Files:
 
законопослушный гражданин:

Could you please advise

how to return the starting lot -Lot, (to open the next order), after the execution of this part of the function:

after

CloseOrder();
add
Start = TimeCurrent();
 

with static in mql everything is running and fraught with errors. The code is always built/compiled as a whole, without intermediate obj and declaration of static is just a tribute to tradition.

If one uses static in mql - that's almost 100% from C/C++/C# world ; or one peeked and ridiculously imitates :-)

but there is also __thread__ :-)

Reason: