GetMAStudy

ICE Data Services -

GetMAStudy() Advanced GET Study Functions

Creates object, which allows to get values of indicator Advanced GET Moving Average in EFS scripts.

 

Syntax

GetMAStudy( nLength , nOffset , PriceSource , bExponential , dPercent1 , dPercent2 , dOptimized )

 

Parameters

Parameter: Description: Default:
nLength Number of periods to use for calculation.

 

n/a
nOffset The number of periods the Moving Average should be shifted forward (+ number) or backwards (- number).

 

n/a
PriceSource String. One of the following values: "Open", "High", "Low", "Close", "HL/2", "HLC/3", "OHLC/4", "Volume".

 

n/a
bExponential Boolean. Exponential Moving Average is used when this parameter is True, Simple Moving Average is used when this parameter is False

 

n/a
Percent1 Is used to adjust where, in relation to the price scale, the Moving Average gets displayed. When both Band One and Band Two are set to 0 (the default setting), only one Moving Average is drawn at the price it was calculated. Increasing this number will move the Moving Average up on the price scale, and decreasing this number will move the Moving Average down the price scale.

 

n/a
Percent2 Is used to adjust where, in relation to the price scale, the Moving Average gets displayed. When both Band One and Band Two are set to 0 (the default setting), only one Moving Average is drawn at the price it was calculated. Increasing this number will move the Moving Average up on the price scale, and decreasing this number will move the Moving Average down the price scale.

 

n/a
dOptimized Should be set as True, if you want the Adjust Bands indicator values to be calculated. The Adjust Bands indicator will cause secondary lines to be displayed above or below the bands whenever the odds favor the price penetrating the bands.

 

n/a

 

Member(s)

Syntax: Returned value:
GetMAStudy.MA Returns the value of MA. Calculates the average price of an issue over a specified period of time. Vertical shifting is defined by parameter Percent1.

 

GetMAStudy.BAND Returns the value of the second MA. Calculates the average price of an issue over a specified period of time. Vertical shifting is defined by parameter Percent2. If Percent2 is equal zero then this series is null-valued.

 

GetMAStudy.OPT1 Returns values of Adjust Bands indicator which causes secondary lines to be displayed above or below (in depends on sign of Percent1) the Band1 (returned by GetMAStudy.MA) whenever the odds favor the price penetrating the band1

 

GetMAStudy.OPT2 Returns values of Adjust Bands indicator which causes secondary lines to be displayed above or below (in depends on sign of Percent2) the Band2 (returned by GetMAStudy.BAND) whenever the odds favor the price penetrating the band2. If Percent2 is equal zero then this series is null-valued.

 

 

Notes

Only available in versions 7.9 or later.

 

Code Example

Creation Object Example:
var xMA = null;

function main(){...if(xMA == null) xMA = new GetMAStudy(20, 0, "Close", true, 10, -10, true);
	var vMA = xMA.getValue(GetMAStudy.MA);
	var vBand = xMA.getValue(GetMAStudy.BAND);
	var vOpt1 = xMA.getValue(GetMAStudy.OPT1);
	var vOpt2 = xMA.getValue(GetMAStudy.OPT2);...
}
MA Indicator:
var fpArray = new Array();
function preMain() {
  askForInput();
  setDefaultBarFgColor(Color.blue, 0);
  setDefaultBarFgColor(Color.red, 1);
  setDefaultBarFgColor(Color.grey, 2);
  setDefaultBarFgColor(Color.grey, 3);
  setStudyTitle("AGET Moving Average");
  setCursorLabelName("MovAvg", 0);
  setCursorLabelName("MA Band", 1);
  setCursorLabelName("MA Opt1", 2);
  setCursorLabelName("MA Opt2", 3);
  setPriceStudy(true);
  var x = 0;
  fpArray[x] = new FunctionParameter("nLength", FunctionParameter.NUMBER);
  with (fpArray[x++]) {
    setName("Length");
    setLowerLimit(1);
    setDefault(20);
  }
  fpArray[x] = new FunctionParameter("nOffset", FunctionParameter.NUMBER);
  with (fpArray[x++]) {
    setName("Offset");
    setLowerLimit(0);
    setDefault(0);
  }
  fpArray[x] = new FunctionParameter("PriceSource", FunctionParameter.STRING);
  with (fpArray[x++]) {
    setName("Price Source");
    addOption("Open");
    addOption("High");
    addOption("Low");
    addOption("Close");
    addOption("HL/2");
    addOption("HLC/3");
    addOption("OHLC/4");
    setDefault("Close");
  }
  fpArray[x] = new FunctionParameter("bExponential", FunctionParameter.BOOLEAN);
  with (fpArray[x++]) {
    setName("Exponential");
    setDefault(false);
  }
  fpArray[x] = new FunctionParameter("dPercent1", FunctionParameter.NUMBER);
  with (fpArray[x++]) {
    setName("Percent1");
    setDefault(0.0);
  }
  fpArray[x] = new FunctionParameter("dPercent2", FunctionParameter.NUMBER);
  with (fpArray[x++]) {
    setName("Percent2");
    setDefault(0.0);
  }
  fpArray[x] = new FunctionParameter("bOptimized", FunctionParameter.BOOLEAN);
  with (fpArray[x++]) {
    setName("Adjust Bands");
    setDefault(false);
  }
}
var prOpt1 = null;
var prOpt2 = null;
var lineV = 0;
var vMA = null;
function main(
  nLength,
  nOffset,
  PriceSource,
  bExponential,
  dPercent1,
  dPercent2,
  bOptimized
) {
  if (vMA == null)
    vMA = new GetMAStudy(
      nLength,
      nOffset,
      PriceSource,
      bExponential,
      dPercent1,
      dPercent2,
      bOptimized
    );
  var movA = vMA.getValue(GetMAStudy.MA);
  var band = vMA.getValue(GetMAStudy.BAND);
  var opt1 = vMA.getValue(GetMAStudy.OPT1);
  var opt2 = vMA.getValue(GetMAStudy.OPT2);
  var sOpt1 = null;
  if (opt1 != null) {
    sOpt1 = formatPriceNumber(opt1);
    if (prOpt1 != null)
      drawLineRelative(
        -1,
        prOpt1,
        0,
        opt1,
        PS_SOLID,
        1,
        Color.grey,
        "adjust1_" + lineV++
      );
  }
  prOpt1 = opt1;
  var sOpt2 = null;
  if (opt2 != null) {
    sOpt2 = formatPriceNumber(opt2);
    if (prOpt2 != null)
      drawLineRelative(
        -1,
        prOpt2,
        0,
        opt2,
        PS_SOLID,
        1,
        Color.grey,
        "adjust2_" + lineV++
      );
  }
  prOpt2 = opt2;
  return new Array(movA, band, sOpt1, sOpt2);
}

 

See Also

Advanced GET Studies