[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 307

 
hoz:

It's not a fitting, it's a kind of auto-fitting :)

A fit without a firm mark is a fit.

Until the main parameters work properly, they must be defined by thinking, trying, testing in the tester, in the demo and in the real game, and so on, until something new comes to your mind that seems better. And all without adjustment, but by logic, theory and practice!

 
Zhunko:
Any variable must first be declared before it can be used. It can be in parameters, it can be at the global library level.


Not only that, it must also be explicitly initiated.
 
hoz:

So here's a function from the library:

Vadim, about functions in the loop You mean what the switch operator returns? But it's not like I'm getting values over the whole number of loop variables. It's just comparing the type of the mask (input variable of the function) I'm getting and then calculating the value of the mask. It turns out that there are no additional calculations. I just select the type of the mask, and that's it! I want to understand what you mean by:

Can you explain?
This assumes what you will do with this function. This is the kind of function that is usually run through history.
FAQ:

Not only that, it must also be initiated explicitly.
Preferably for order, but in MQL4 they are initialized with zeros by default when declared.
 
I have faced a problem recently: how to know that the indicator, which we use in the Expert Advisor through iCustom() has been initialized and we can take data from it? Other times, there are situations when the chart does not have time to display its objects and the EA is trying to take some data from its buffers. As a result, sometimes zero values appear. Of course, I have checked for non-zero values and only then let the EA continue its operation, but ... maybe there is a more elegant solution?
 

One more thing: I have encountered a strange (for me) behaviour of UninitializeReason(). I check its value in the Inite, and if the timeframe has been changed and there are open positions, then I need to issue a request to close them. If we initially run the EA on M5, and then switch to another timeframe, then there will be no request. If we go back to the initial TF (M5), there will be a request. I think this is not normal. I need to have a request at any change of TF.

Can anyone explain?

 
artmedia70:

One more thing: I have encountered a strange (for me) behaviour of UninitializeReason(). I check its value in the Inite, and if the timeframe has been changed and there are open positions, then I need to issue a request to close them. If we initially run the EA on M5, and then switch to another timeframe, then there will be no request. If we go back to the initial TF (M5), there will be a request. I think this is not normal. I need to have a request at any change of TF.

Can anyone explain?

Make it work, DeinitReason is a global variable

int deinit()
  {
//----
   DeinitReason = UninitializeReason( );
   Print("DeinitReason ",DeinitReason);
//----
   return(0);
  }
 
Mislaid:

Make it work, DeinitReason is a global variable

Exactly. The Reason global variable gets a value, but it gets it not in deinit(), but in init(), so that when init() is run, you can see the reason for the last deinitialisation and, based on the value, execute one action or another. But it does not work as it should.
 

Good afternoon.A new question has arisen.Help please.For the knowledgeable there is a minute, but for beginners is difficult.Googled nothing helps, but maybe someone has faced.

The journal says

(2013.04.23 10:06:30 2013.04.01 00:00 xrust EURUSD,M1: 2 parameter for SetIndexBuffer function must be array).

https://forum.mql4.com/ru/55137#786974

 
palomnik:

Good afternoon.A new question has arisen.Help please.For the knowledgeable there is a minute, but for beginners is difficult.Googled nothing helps, but maybe someone has faced.

The journal says

(2013.04.23 10:06:30 2013.04.01 00:00 xrust EURUSD,M1: 2 parameter for SetIndexBuffer function must be array).

https://forum.mql4.com/ru/55137#786974


It says that the second parameter in SetIndexBuffer function must be an array. That is, not double znach1, but double znach1[]
 
How do I run the script I just edited without restarting mt4?
Reason: