iRSIOnArray Issues

 

Hi All,

Could someone help me with how to use the iRSIOnArray function.

For example, why does this not work?

double RSI = iRSIOnArray(Close,0,10,0);

I'm just playing around with it to try and understand how it works. When I run this it returns zero. I assumed the Close array would be fine to test it with and a basic 10 period.

My goal is to read in some data from a text file and calculate RSI on the values, but obviously need to get it working on live chart values first.

Thanks.

 
double RSI = iRSIOnArray(Close,0,10,0);
Why do you expect an RSI on a Close[] array that has 0 elements to return anything useful?
 
whroeder1:
Why do you expect an RSI on a Close[] array that has 0 elements to return anything useful?


From the documentation

[in]  The number of items to be counted. 0 means the whole array.

 
James Parker:

Hi All,

Could someone help me with how to use the iRSIOnArray function.

For example, why does this not work?

Where do you place your code?

If you place it in OnInit, the Close array will not be loaded, so it will return 0.

 
Keith Watford:

Where do you place your code?

If you place it in OnInit, the Close array will not be loaded, so it will return 0.


This is within the OnTick function.

I was just using the Close array as an example.

Originally I read some data from a file into an array that I created and tried to calculate the iRSIOnArray on it, but it returned 0. So I started to think maybe it is something wrong with the array that I have created. So instead I test it on one of the predefined arrays that I know must be correct but still I get 0.

 

It is not a function that I have used much, but I have tested it and it does just seem to return 0.0

So it appears that the function is not working as it should.

 
Keith Watford:
whroeder1:
Why do you expect an RSI on a Close[] array that has 0 elements to return anything useful?

From the documentation

[in]  The number of items to be counted. 0 means the whole array.

Do you really want the RSI for the last 20,000 bars? That will be a flat line.
 
whroeder1:
Do you really want the RSI for the last 20,000 bars? That will be a flat line.


I was under the impression that it means it will take the whole array, but only calculate RSI on the last 10 bars.

Either way there is something wrong with the code or function as the answer returns 0 whether I use:

double RSI = iRSIOnArray(Close,0,10,0);

or:

double RSI = iRSIOnArray(Close,10,10,0);

So I'm not sure what is going wrong...

Reason: