smoothOsc() Built-in Study Functions
The Smoothed Oscillator displays the simple difference between two smoothed moving averages of a price. It can be used to help identify divergences, short-term variations from the long-term trend, and to identify the crossing of two smoothed moving averages, which occur when the oscillator crosses the zero line.
Syntax
smoothOsc( nFastLength , nSlowLength [, Series | sym() | inv() ][, nBarIndex ] )
Parameters
Parameter: | Description: | Default: |
nFastLength | Required. Number for the fast period length to use for the calculation. | n/a |
nSlowLength | Required. Number for the slow period length to use for the calculation. | n/a |
Series or sym() or inv() |
[Optional] Series Object or function of sym() or inv() to determine symbol/interval source for the study. | Base sym/inv |
nBarIndex | [Optional] Bar index of series to retrieve . | n/a |
Return Value(s)
Returns a Series Object when nBarIndex is not specified.
Returns a single value when nBarIndex is specified.
Notes
Only available in versions 12.1 or later.
Code Examples
function main() { return smoothOsc(5, 10); }
function main() { return smoothOsc(5, 10, hl2()); }
function main() { var nValue_0 = smoothOsc(5, 10, 0); // Current Bar Index var nValue_1 = smoothOsc(5, 10, -1); // Prior Bar Index return new Array(nValue_0, nValue_1); }
var xStudy = null; function main() { if (xStudy == null) { xStudy = smoothOsc(5, 10); } // retrieve single values for conditional statements var nValue_0 = xStudy.getValue(0); // Current Bar Index value var nValue_1 = xStudy.getValue(-1); // Prior Bar Index value return nValue_0; // Plot Current Bar Index Value }
var xStudy = null; var bInit = false; // Initialization flag function main() { if (bInit == false) { xStudy = smoothOsc(5, 10, inv(20)); // 20-min interval bInit = true; } // retrieve single values for conditional statements var nValue_0 = xStudy.getValue(0); // Current Bar Index value var nValue_1 = xStudy.getValue(-1); // Prior Bar Index value return getSeries(xStudy); // Synchronized Series plot }
var xStudy = null; var bInit = false; // Initialization flag function main() { if (bInit == false) { xStudy = smoothOsc(5, 10, sym("IBM,20")); // IBM 20-min interval bInit = true; } // retrieve single values for conditional statements var nValue_0 = xStudy.getValue(0); // Current Bar Index value var nValue_1 = xStudy.getValue(-1); // Prior Bar Index value return getSeries(xStudy); // Synchronized Series plot }See Also
Series Object
getSeries()
Built-in Study Functions
eSignal Forum Search Engine
Help Guides and Tutorials