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

 
str+="--LoY["+IntegerToString(r)+"]--, "+DoubleToString(LoY[r],4)+", ";
 
ANDREY:

I got what I need

LoY[r] = 1.6104---LoY[r] = 1.6105---LoY[r] = 1.6106---LoY[ r] = 1.6107---LoY[r] = 1.6108---LoY[r] = 1.6109---LoY[r] = 1.6110---LoY[r] = 1.6111....

And can I also askPrint() to substitute index values instead of [r].
I will be very grateful if you could write an example of such a code instead of explaining it in words.
Thank you for your help.

This only happens to me during seizures......... One seizure has already happened to me today, the next one won't happen any time soon...

 
Aleksei Stepanenko:

Thank you very much for your help. Your code is more compact and so I am taking it on board and proceeding to study it carefully to understand it in great detail.

 
Aleksei Stepanenko:

I have studied your code carefully. Understood every single character. I don't understand only the + signs in red

str+="--LoY["+IntegerToString(r)+"]--,"+DoubleToString(LoY[r],4)+",";
I'd appreciate if you could tell me what function these pluses perform and where to read about them. I couldn't find information about them in Kovalev's tutorial.
When I removed these options the compiler gave me some errors. Unfortunately I'm no good at English, so I don't know what he meant by that.

Thanks again for the informational support.

 
ANDREY:

I have studied your code carefully. Understood every single character. I don't understand only the + signs in red

str+="--LoY["+IntegerToString(r)+"]--,"+DoubleToString(LoY[r],4)+",";
I'd appreciate if you could tell me what function these pluses perform and where to read about them. I couldn't find information about them in Kovalev's textbook.
When I removed these options the compiler gave me some errors. Unfortunately I'm no good at English, so I don't know what he meant by that.

Thanks again for the informational support.

And here are explanations in words, please.........

If you add up numbers, for example 2.3+3.6, the same number, 5.9, and if you add up strings DoubleToString(2.3, 1)+ DoubleToString(3.6, 1), it will be 2.33.6 as a string.

 

That's right Alexey said, it's just stringing together.

This might be of interest to you:

a+=4; -это тоже самое, что и a=a+4;
по аналогии:
a-=4;
a*=4;
a/=4;

a++; - означает a=a+1;
a--;

 
Alexey Viktorov:

But explanations in words are welcome.........

If you add up numbers, for example 2.3+3.6, it will be the same number, 5.9, and if you add up strings DoubleToString(2.3, 1)+ DoubleToString(3.6, 1) then it will be 2.33.6 as a string.

Thanks for the tip.

 
Aleksei Stepanenko:

That's right Alexey said, it's just stringing together.

That might be of interest to you:

Thanks for the tip.

 
Alexey Viktorov:

But here's an explanation in words, please.........

If you add up numbers, e.g. 2.3+3.6, it will be the same number, 5.9, and if you add up strings DoubleToString(2.3, 1)+ DoubleToString(3.6, 1), it will be 2.33.6 as a string.

That is, at each iteration the value of LoY["IntegerToString(r)"] is incremented by 1 and the value of DoubleToString(LoY[r],4) is incremented by 1.

But the increment by 1 is not arranged in the way I'm used to LoY["IntegerToString(r)"]++; But the increment by 1 is arranged speciallyLoY["+IntegerToString(r)+"], i.e. the variable is placed between pluses.

How should we handle increasing a string variable by 2 instead of 1? Normally this increment is VARIABLE +=2, but how should I format increment by 2 in my code?

Further, the values of my array elements will go differently from each other, and not in strict order like now. For example, it will be like this....

LoY[0]= 1.6104, LoY[1]= 1.6114,LoY[2]= 1.6100,LoY[3]= 1.6120, LoY[4]= 1.6115, LoY[5]= 1.6115, LoY[6]= 1.6098,LoY[7]= 1.6085, LoY[8]= 1.6125,..... and so on. In other words, these values will be assigned to array items in a different part of the code and not necessarily using a loop.
I don't think we can correctly display such a sequence in the Print() function
using string variables connection......


Thanks for the help.

 
ANDREY:

That is, at each iteration the value of LoY["IntegerToString(r)"] is incremented by 1 and the value of DoubleToString(LoY[r],4) is incremented by 1.

But the increment by 1 is not arranged in the way I'm used to LoY["IntegerToString(r)"]++; But the increment by 1 is arranged speciallyLoY["+IntegerToString(r)+"], i.e. the variable is placed between pluses.

How should we handle increasing a string variable by 2 instead of 1? Normally this increment is VARIABLE +=2, but how should I format increment by 2 in my code?

Further, the values of my array elements will go differently, not strictly as they are now. For example, it will be like this....

LoY[0]= 1.6104, LoY[1]= 1.6114,LoY[2]= 1.6100,LoY[3]= 1.6120, LoY[4]= 1.6115, LoY[5]= 1.6115, LoY[6]= 1.6098,LoY[7]= 1.6085, LoY[8]= 1.6125,..... and so on. In other words, these values will be assigned to array items in a different part of the code and not necessarily using a loop.
I don't think we can correctly display such a sequence in the Print() function
using string variables connection......


Thank you for your help.

The IntegerToString() and DoubleToString() functions just represent a number as a string that is passed into the function. Here is an example

This is exactly where the r number is converted to a string and the strings are "added". But before that the value of r changes.

I don't quite understand the question, but if you want to select only even-numbered elements from the array, the loop should be built like this

for(int i = 0; i <= 30; i+=2)


Reason: