Hello all
I want to create an array from 9 values and then measure mean of the array. I used the Operator 'for' but I do not know how to extract values from it. want to do is to extract these trmax values from the loop and use it out of the loop. Any idea how to do so? Here is my code:
Thanks in advance
Hello,
Setting them in the void OnInit() {} function would be the best option.
So you need to save the values outside of the function it runs in. Pretend you are taking 9 steps and for each step you write down the distance.
If you save the values inside the function, it's like writing down the same number for each step you take. You need to use that step to write down that value inside it.
So let's say you use the onTimer function after you've set the size of the array (using arrayResize).
Let's call your array arrThree; So the data type would be double[], because it is a decimal (which is what a double is) and the [] means it is an array holding multiple values.
Then to save the first value in the array, you would use arrThree[0].
To save the second value, you would use arrThree[1];
And then you do this up to arrThree[9].
But this is why you have a loop. You don't need to insert a decimal at step 0 or 9. You can just use i instead.
- www.mql5.com
Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello all
I want to create an array from 9 values and then measure mean of the array. I used the Operator 'for' but I do not know how to extract values from it. want to do is to extract these trmax values from the loop and use it out of the loop. Any idea how to do so? Here is my code:
Thanks in advance