[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 370
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good afternoon!
Can you give me a hint, please.....
Indic_mas[]//main array
Indic_mas_copi[]//array to which the main array is copied.
n //number of elements in Indic_mas_copi[]
1. does the entry Indic_mas_copi[n]=0 mean that we have zeroed all elements of the array?
2. After performing certain operations, the array Indic_mas_copi[] has changed the values of some elements,
The next iteration repeats copying Indic_mas[] into Indic_mas_copi[].
Does Indic_mas_copi[] need to be zeroed (or empty) before this copying
or will Indic_mas[] elements automatically replace the previous Indic_mas_copi[] elements ?
Good afternoon!
Can you give me a hint, please.....
Indic_mas[]//main array
Indic_mas_copi[]//array to which the main array is copied.
n //number of elements in Indic_mas_copi[]
1. does the entry Indic_mas_copi[n]=0 mean that we have zeroed all elements of the array?
2. After performing certain operations, the array Indic_mas_copi[] has changed the values of some elements,
The next iteration repeats copying Indic_mas[] into Indic_mas_copi[].
Does Indic_mas_copi[] need to be zeroed (or empty) before this copying
or will Indic_mas[] elements automatically replace previous Indic_mas_copi[] elements ?
1. If n is the number of elements in Indic_mas_copi[], then writing Indic_mas_copi[n] is not correct because you are going outside the array in this entry. Do not forget that numbering of array cells starts from zero cells. Therefore, the number of the last cell of the array you can address is n-1
2. will be replaced. Check this with the script.
1. If n is the number of elements in Indic_mas_copi[], then writing Indic_mas_copi[n] is not correct because you are going outside the array in this entry. Do not forget that numbering of array cells starts from zero cells. That's why the number of the last array cell to be addressed is n-1.
2. there will be substitutions. Check it with the script.
Thank you very much, Vladimir!
Then to zero the elements of the array you need the following?
Thank you very much, Vladimir!
Then to zero the elements of the array you need the following?
No - it's too complicated. There is a simpler way.
Thank you very much, Vladimir!
Then to zero the elements of the array you need the following?
ArrayInitialize(Array_Name,0);
This is better: https://docs.mql4.com/ru/array/ArrayInitialize - there is a concrete code example
No - this is too complicated. There is a simpler way.
Thank you. It really is easier that way.
Then the loop can be used in a situation where we need to zero some of the elements?
Or, say, through a single element.
Good afternoon!
Can you give me a hint, please.....
Indic_mas[]//main array
Indic_mas_copi[]//array to which the main array is copied.
n //number of elements in Indic_mas_copi[]
1. does the entry Indic_mas_copi[n]=0 mean that we have zeroed all elements of the array?
2. After performing certain operations, the array Indic_mas_copi[] has changed the values of some elements,
The next iteration repeats copying Indic_mas[] into Indic_mas_copi[].
Does Indic_mas_copi[] need to be zeroed (or empty) before this copying
or will Indic_mas[] elements automatically replace the previous Indic_mas_copi[] elements ?
Thank you. It's really simpler that way.
Then the loop can be used in a situation where you need to zero out some of the elements?
Or, say, through one element.
A loop can be used when you want to zero or reinitialise some elements... A loop, on the other hand, goes through them all one by one. Therefore, inside the loop we can introduce a rule that will sort the required cells of the array. For example, we only need to sort out negative numbers and double them. Therefore we will write the following in the loop
If the value in the current cell of the array is less than zero, then it takes the value of that cell of the array multiplied by two. Otherwise, continue
P.S.
Although from the processor's point of view, if we know ahead of time exactly what we need to double, it's better to apply addition than multiplication - addition will take less CPU time.