RSI |
Top Previous Next |
rsi( length [, source | sym() | inv()] [, barIndex] )
The Relative Strength Index (RSI) is designed to indicate a market's current strength or weakness depending on where prices close during a given period. It is based on the premise that higher closes indicate strong markets and lower closes indicate weak markets. The RSI is displayed as three lines, the RSI and two moving averages of the RSI. The RSI is calculated by finding the percentage of positive closes (the current close is higher than the previous close) to negative closes (the current close is lower than the previous close).
Parameters
To Create a Series
var myStudy = null; var bInit = false;
function main() { var myVar;
if ( bInit == false ) {
myStudy = rsi( 14 ); bInit = true;
}
//retrieve the current value myVar = myStudy.getValue(0);
return( myVar );
}
To Retrieve a Single Value
function main() {
... ... myVar = rsi( 14 );
//do something with the value in myVar
}
Calling Examples
//create a study that uses IBM as the symbol along with whatever bar //interval you are using in the chart where the script is loaded myStudy = rsi( 15, sym( "IBM") );
//create a study that uses the 15-min bar interval, regardless of the bar //interval of the chart in which the script is loaded myStudy = rsi( 15, inv(15) );
//create a study that uses the Daily bar interval, regardless of the bar //interval of the chart in which the script is loaded myStudy = rsi( 5, inv("D") );
//create a study that will be based on MSFT 30-min bars, regardless of //the symbol/bar interval of the chart in which the script is loaded myStudy = rsi( 14, sym( "MSFT,30" ) );
//create a study that will be based on the high. myStudy = rsi( 15, high() );
//create a study that will be based on the close, using 15-min bars, regardless of //the bar interval of the chart in which the script is loaded myStudy = rsi( 20, close( inv(15) ) );
|