[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 60

 
TheXpert >> :

Remembered! A peculiarity of string implementation. After the array is resized, it has to be walked through and zeroed out:

I could be wrong but it should help.

Thanks for the reply. Tried it, but unfortunately it didn't help. Zeroing acts before we start doing something with the array. And zeroing is done through explicit assignment of string VALUE, while in the case I have pointed out, the array elements are assigned the result of the function (which should return VALUE of string type) but actually returns a REFERENCE to the address of string in memory, which I believe is incorrect. And the result with identical values is because the function is called several times in a row and after each call the next one actually uses the same memory, putting there new data. If we do any manipulations between calls (calls of any f-ions, declaration of variables, etc) the result will most likely be even worse, namely values in string array element will point to rubbish in memory.


I would like the mql4 developers to comment on this situation and explain the correct way of working with string arrays, if possible.

 
xruss писал(а) >>
is there some kind of error?

The last closed order from the history is selected and its type is assigned to the ORDtype variable before the signal to open is generated. I.e., if the history is not empty, then ORDtype will obviously not equal -1. Therefore, the condition for the signal to appear is not fulfilled since

if ((ORDtype==-1)&&(...))

 
Everlost >> :

The last closed order from the history is selected and its type is assigned to the ORDtype variable before the opening signal is generated. I.e., if the history is not empty, then ORDtype will obviously not equal -1. Therefore, the condition of signal occurrence is not fulfilled since

if ((ORDtype==-1)&&(...))

And one more problem - positions are not opened even if the history is empty ((

 
Yug >> :

Thanks for the reply. Tried it, but unfortunately it didn't help. Zeroing works before we start doing anything with the array. And zeroing is done through explicit assignment of string VALUE, while in the case I have pointed out, the array elements are assigned the result of the function (which should return VALUE of string type) but actually returns a REFERENCE to the string address in memory, which I believe is incorrect. And the result with identical values is because the function is called several times in a row and after each call the next one actually uses the same memory, putting there new data. If you do any manipulations between calls (calls of any fonts, declaration of variables, etc.) the result will most likely be even worse, namely, values in string array element will point to rubbish in memory.


I'm asking mql4 developers to comment on this situation if possible and explain how to work with string arrays correctly.

Try it this way:

string tmp = func();
array[0] = tmp;

A vegetable garden, of course, but it should work...

 

What does MT4 mean in the tester -Optimisation, where do I tick? What is this function? Does it tune the EA to some specific settings (standard) or does it show on what period (TF) it works better?

 
rafex >> :

What does MT4 mean in the tester -Optimisation, where do I tick? What is this function? Does it tune the EA to some specific settings (standard) or does it show on what timeframe (TF) it works better?

This checkbox can be touched only after you press F1 and carefully study "Autotrading" section.

 
komposter >> :

Try it this way:

A vegetable garden, of course, but it should work...

I tried it the day before yesterday. The result is the same. Actually the reference is copied to temp str first, and then the same reference is copied to an array element :(

 
Yug >> :

I tried it the day before yesterday. The result is the same. Actually the reference is first copied to temp str and then it is copied to array element :(

Declare the return string as static in the function, only then the initialization must be done after the declaration.

 
Dear experts, please don't ignore my question.

Is there an indicator that counts volatility, for example daily. But not the one, that gives an undefined number like 0.34. But it should calculate the number of candlesticks per day and divide it by a given period (number of days) so that the indicator knows the average value. Example: Opening 100, closing 200; the second day - opening 200, closing 250. Average volatility for these 2 days = ((200-100)+(250-200))/2 days=(100+50)/2=75
Where to download if available.
 
TheXpert >> :

Declare the return string as static in the function, but then the initialisation must be done after the declaration.

I tried this variant too. The result is the same, i.e. memory reference is returned instead of value.

Reason: