Parabolic SAR

ICE Data Services -

sar() Built-in Study Functions


The Parabolic SAR study is a display of "Stop and Reverse" points for a particular market. When the market touches or crosses a point, this indicates that a positions should be reversed. If the current position is long, for example, go short. If the current position is short, go long. The Parabolic SAR assumes that you are always in the market.


Syntax

sar( nStart , nIncrement , nMax [, Series | sym() | inv() ][, nBarIndex ] )


Parameters

Parameter: Description: Default:
nStart Required. Number for starting SAR value. n/a
nIncrement Required. Number for the acceleration factor. n/a
nMax Required. Number for the maximum SAR value. n/a
Series or
sym() or
inv()
[Optional]  Series Object or function of sym() or inv() to determine symbol/interval source for the study. Chart's 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 7.9 or later.

The plot type for this study is typically set to PLOTTYPE_DOT in preMain() (see setPlotType()).

 

Code Examples

Single Line Indicator:
function main() {
  return sar(0.02, 0.02, 2);
}

 

Single Line Study-on-Study Indicator:
function main() {
  return sar(0.02, 0.02, 2, hl2());
}

 

Retrieve single values:

function main() {
  var nValue_0 = sar(0.02, 0.02, 2, 0); // Current Bar Index
  var nValue_1 = sar(0.02, 0.02, 2, -1); // Prior Bar Index
  return new Array(nValue_0, nValue_1);
} 
 
Initialize a Series Object:
var xStudy = null;
function main() {
  if (xStudy == null) {
    xStudy = sar(0.02, 0.02, 2);
  } // 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
}

 

Initialize a Series Object based on an external interval:
var xStudy = null;
var bInit = false; // Initialization flag
function main() {
  if (bInit == false) {
    xStudy = sar(0.02, 0.02, 2, 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
}

 

Initialize a Series Object based on an external symbol and interval:
var xStudy = null;
var bInit = false; // Initialization flag
function main() {
  if (bInit == false) {
    xStudy = sar(0.02, 0.02, 2, 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