CustomFuncRef.efs

ICE Data Services -


CustomFuncRef.efs 
  

File Name: CustomFuncRef.efs


Description:
This formula outlines a method for referencing past values of an indicator using a global array. This is an alternative method to using the ref() function.


Formula Parameters:
NA

Notes:
The chart plots the midpoint displaced by 10 bars to the right. If ref() is used in a formula that is being called by call() or callFunction(), you may experience unexpected results. Use this method as a work around.

Download File:
CustomFuncRef.efs




EFS Code:
/*******************************Provided By : eSignal. (c) Copyright 2003*******************************/// Updated: 01/27/03function preMain() {    setPriceStudy(true)    setStudyTitle("How to reference past values of custom indicator using an array.");    setDefaultBarFgColor(Color.blue)    setCursorLabelName("Value ");}var myArray = new Array(10);var myValue = null;function main() {       var nBarState = getBarState();        if (nBarState == BARSTATE_NEWBAR && myValue != null) {        myArray.pop();              //removes last array element        myArray.unshift(myValue);   //inserts array element to the front of the array     }    myValue = ((high() + low()) / 2);    if (myValue == null) {        return;    }         if (myArray[9] != null) {        return myArray[9];    } else {        return;    }}