REQUIREMENTS
eSignal version 7.9.1 build 732 or later is
required to use the ezArray() function.
INSTALLING THE LIBRARY
Save the easyArray.efsLib file in the FunctionLibrary
folder of the eSignal directory.
SYNTAX
syntax |
ezArray(value, length, TagName); |
value |
the variable for which you want to create an array. It can be any variable you have computed in the efs (as in the examples shown below) or even an equation that you are passing directly such as for example var
myArray = (high(0)-low(0), 10, "array1") |
length |
the
length of the array |
TagName |
can be a number or a string and must be unique to each array that is
being created. |
IMPORTANT NOTES- All parameters are required - The name of the variable assigned to the array AND the TagName
must be unique to each array (even when creating multiple arrays for the same
value). If the name of the variable OR the TagName are
not unique you could have incorrect results. |
In the efs in which you need to create and maintain one (or
more) arrays add the call to load the easyArray.efsLib library
function preMain(){
setPriceStudy(true);
setStudyTitle("example0");
}
var myLib =
addLibrary("easyArray.efsLib"); //this is the call to load the library
function main(){
var myVar =
(high(0)+low(0))/2;
return (myVar);
}
Depending on the requirements of your script you may need to
create the array before or after having computed the variable for which you
need an array.
The ezArray()
function allows you to do either with only a slight change in the code.
In this first example you can see how to create the array
after having computed the variable for which you need an array
function preMain(){
setPriceStudy(true);
setStudyTitle("example1");
setCursorLabelName("Current Value1",0);
setCursorLabelName("Prior Value1",1);
setDefaultBarFgColor(Color.blue,0);
setDefaultBarFgColor(Color.red,1);
}
var myLib =
addLibrary("easyArray.efsLib"); //this is the call to load the library
function main(){
var myVar = (high(0)+low(0))/2; //variable for which we
need an array
var myArray = myLib.ezArray(myVar, 5, "array1"); //this calls the ezArray()
function to create and maintain the array
if(myArray[5-1] == null) return; //perform a null check on
the oldest element of the array ie myArray[length of array –1]
return new Array (myArray[0], myArray[1]);
}
In this second example instead the array is created prior to computing the variable for which you need an array.
function preMain(){
setPriceStudy(true);
setStudyTitle("example2");
setCursorLabelName("Current Value1",0);
setCursorLabelName("Prior Value1",1);
setDefaultBarFgColor(Color.blue,0);
setDefaultBarFgColor(Color.red,1);
}
var myLib =
addLibrary("easyArray.efsLib"); //this is the call to load the library
var myVar = null;
function main(){
var myArray = myLib.ezArray(myVar, 5, "array2"); //this calls the ezArray()
function to create and maintain the array
myVar = (high(0)+low(0))/2; //variable for which we need an array
if(myArray[5-1] == null) return; //perform a null check on
the oldest element of the array ie myArray[length of array –1]
myArray[0] = myVar; //required to update the most recent element of
the array after the variable is calculated
return new Array (myArray[0], myArray[1]);
}
Notice that in this case after we have computed the variable
we need to refresh the most recent element of the array with the latest value
of the variable.
This is the only change that is required by this logic.
DISCLAIMER: The easyArray
Library is for personal use only and is provided as-is with no warranties
and/or guarantees. Reproduction, duplication, or redistribution of the easyArray
Library, in any form, without prior written permission from the author, is
strictly prohibited. The author reserves the right to change at any time part
or all of the easyArray Library.