[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 184
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
If it outputs zeros, it's better to attach code rather than explaining it on your fingers.
If an open array is declared, it is advisable to do ArrayResize, or declare a larger dimension right away.
The script is purely for fun, but you can also catch Alert(GetLastError()); getting
If it outputs zeros, it's better to attach code rather than explaining it on your fingers.
If an open array is declared, it's advisable to do ArrayResize, or declare a larger dimension right away.
I have already attached the code in the first post. There just need to add a couple of correct lines somewhere to form the array. That was exactly the main question).
In fact, I think it should be something like this somewhere:
ArrayResize(Mas,n);
Mas[n]={diff};
n is the new dimensionality, diff values of the resulting differences.
But it doesn't work that way, it prints the difference 0.00000. I have already tried to insert the difference in the loop, behind the loop and even in the condition.
In short, I am in a stupor).
If you know how to write it, I will be very grateful to you.
The script is purely for fun, but you can also catch Alert(GetLastError()); getting
Well, it turns out that you explicitly specify both the array's size and value in the code. It is this very thing that I have understood in the article.
But it somehow does not work with my example.(.
explicitly specify both the dimension and the value of the array in the code
There are no other options.
Elements are not created when you access them.
There are no other options.
Elements are not created when they are accessed.
Okay, look. Do I get it right?
In your example, you're creating a one-dimensional array consisting of a single value of 89.
By the way, by dimensionality I meant the number of elements in a one-dimensional array. I thought that you can change it over the course of the program. After all, it's not for nothing that we initially specify our array not explicitly. I.e. for example:
double Mas[]; //initialize one-dimensional array
int n=0; //will be useful for the number of array elements
Further, like in my example, we do the following loop
for(...)
{
if(...)//the condition we are interested in
{
n++;// count how many times it worked
diff=... values we are interested in
}
}
and then somewhere else we stuff our one-dimensional array Mas[n] with diff values, n being the number of elements
I thought it's quite normal and can be done that way... Or is it?
Before for, add an ArrayResize to the required number of elements
For example, the point
is oriented on the number of bars in the chart in the current window, or you can just specify any close to astronomical number instead of iBars.
The array is initially created empty, before accessing it, you need to specify how many elements you want to store in it. Post the full code, it will be easier to navigate.
Before for, add an ArrayResize to the required number of elements
For example, the point
is oriented on the number of bars of the chart in the current window, or you can just specify any close to astronomical number instead of iBars.
In the example I show that you can't use an array that doesn't have a number of elements marked.
The first two calls cause an error and return 0.
To get rid of the cockroaches, just write
double mas[999999];
If it works, deal with the cockroaches.
In the example I show that you can't use an array that doesn't have a number of elements marked.
The first two calls cause an error and return 0.
To get rid of the cockroaches you've got.
If it works, deal with the cockroaches.
You don't have to specify number of elements from the beginning, double Mas[] construction is also suitable.