shawnyau:
double a[];
for (int i=0; i<Bars; i++)
{
a[i] = (3*Close[i]+Open[i]+High[i]+Low[i])/3;
}
.........
what`s wrong with the code above?the a[i] seems get nothing?when I used Print() to check the a[i], I found a[i] is zero,why? can somebody help me ? Thanks!
The size of a[] has to be defined, either a[1000] or whatever number, or use ArrayResize().
double a[];
for (int i=0; i<Bars; i++)
{
a[i] = (3*Close[i]+Open[i]+High[i]+Low[i])/3;
}
.........
what`s wrong with the code above?the a[i] seems get nothing?when I used Print() to check the a[i], I found a[i] is zero,why? can somebody help me ? Thanks!
In this case:
double a[];
ArrayResize(a, Bars);
... because he is going to fill it with that many values. The array must be sized to hold the number of elements you plan to store.
thank you!

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
for (int i=0; i<Bars; i++)
{
a[i] = (3*Close[i]+Open[i]+High[i]+Low[i])/3;
}
.........
what`s wrong with the code above?the a[i] seems get nothing?when I used Print() to check the a[i], I found a[i] is zero,why? can somebody help me ? Thanks!