why the value of them is zero

To add comments, please log in or register
Vaclav
53
Vaclav  

Dear expert:

I use history data of auto trade system to test the function,the value of RSV is zero,Please tell me why?

while(i>=0)
{
MaxHigh=High[iHighest(NULL,0,MODE_HIGH,nPeriod,i)];
MinLow=Low[iLowest(NULL,0,MODE_LOW,nPeriod,i)];
if (MaxHigh-MinLow != 0) RSV[i]=(Close[i]-MinLow)/(MaxHigh-MinLow)*100;
else RSV[i] = 50;
i--;
}

thanks!


Vaclav
53
Vaclav  

If anyone can give me answer?

thanks!

Ubzen
5299
Ubzen  

What is RSV? Use print to check the value of i.

Vaclav
53
Vaclav  

RSV is a buffer, if I set a element of it to a value, for example,

RSV[0] = 50,I print it, it displays 0, why?

Simon Gniadkowski
17271
Simon Gniadkowski  
sniff:

RSV is a buffer, if I set a element of it to a value, for example,

RSV[0] = 50,I print it, it displays 0, why?

How did you declare the buffer/array ? is it a Buffer or an Array ? is this in an Indicator or an EA ?
Vaclav
53
Vaclav  

it is a global variable

double RSV[];

Simon Gniadkowski
17271
Simon Gniadkowski  
sniff:

it is a global variable

double RSV[];

OK, if it's not a Indicator buffer you have to define how many elements are in the Array, otherwise it has 0 elements and then all it's values . . . all 0 of them, are 0.

You need to do this . . .

double RSV[1000];  <------ adjust to the number you need or use ArrayResize()
Vaclav
53
Vaclav  

Do you know how to get the value of array element?

thanks!

Simon Gniadkowski
17271
Simon Gniadkowski  
sniff:

Do you know how to get the value of array element?

thanks!

Yes . . . arrayname[arrayelementnumber], note, first element number is 0
William Roeder
22318
William Roeder  
sniff:

RSV is a buffer, if I set a element of it to a value, for example,

RSV[0] = 50,I print it, it displays 0, why?

If it displays zero, how do you know it's 50?
Vaclav
53
Vaclav  

thank your help, the value of RSV is correct.there is another question,please see the code.

double percentK[512];

double RSV[512];

limit=Bars-counted_bars;
if(limit > 512) limit = 512;
//---- signal line is simple movimg average
for(i=0; i<limit; i++)
{
percentK[i]=iMAOnArray(RSV,Bars,M1,0,MODE_SMA,i);

}

the percentK[i] value is -0,why?

12
To add comments, please log in or register