Price Oscillator |
Top Previous Next |
osc( fastLength, slowLength, bExponential [, source | sym() | inv()] [, barIndex] )
The Price Oscillator displays the difference between two moving averages of a security's price. The difference between the moving averages can be expressed in either points or percentages.
Parameters
To Create a Series
var myStudy = null; var bInit = false;
function main() { var myVar;
if ( bInit == false ) {
myStudy = osc( 10, 21, false ); bInit = true;
}
//retrieve the current value myVar = myStudy.getValue(0);
return( myVar );
}
To Retrieve a Single Value
function main() {
... ... myVar = osc( 10, 21, false );
//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 = osc( 10, 21, false, 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 = osc( 5, 10, false, 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 = osc( 15, 31, true, 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 = osc( 10, 21, false, sym( "MSFT,30" ) );
//create a study that will be based on the high. myStudy = osc( 10, 21, false, 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 = osc( 10, 21, true, close( inv(15) ) );
|