Announcement
Collapse
No announcement yet.
performancecomp.efs
Collapse
X
-
Try:
PHP Code:/****************************************************************************************************
Copyright © eSignal, a division of Interactive Data Corporation. 2003. All rights reserved.
This sample eSignal Formula Script (EFS) may be modified and saved under a new
filename; however, eSignal is no longer responsible for the functionality once modified.
eSignal reserves the right to modify and overwrite this EFS file with each new release.
*****************************************************************************************************/
/** Updated: 01/14/03 **/
/** added more symbols 20130802 **/
debugClear();
function preMain() {
setStudyTitle("\% Performance ... Add Symbol(s)");
var aFPArray = new Array();
var x = 0;
aFPArray[x] = new FunctionParameter("Symbol0", FunctionParameter.STRING);
with(aFPArray[x++]){
setDefault(getSymbol());
}
for(x=1; x<20; x++) {
var fpLabel = "Symbol"+x;
aFPArray[x] = new FunctionParameter( fpLabel, FunctionParameter.STRING);
with(aFPArray[x++]){
setDefault( );
}
}
askForInput();
}
var vLoaded = false;
var vBase;
var b;
var vSymbols;
var vCalcStart = false;
function main(Symbol0,Symbol1,Symbol2,Symbol3,Symbol4,Symbol5,Symbol6,Symbol7,Symbol8,Symbol9,Symbol10,Symbol,Symbol11,Symbol12,Symbol13,Symbol14,Symbol15,Symbol16,Symbol17,Symbol18,Symbol19) {
var cntr=0;
if (vLoaded == false) {
vSymbols=[];
var ClrArr=[Color.blue,Color.red,Color.green,Color.cyan,Color.lime,Color.magenta,Color.brown,Color.black,Color.purple,Color.teal,
Color.aqua,Color.darkgreen,Color.darkgrey,Color.khaki,Color.maroon,Color.navy,Color.olive,Color.RGB(210,193,522),Color.RGB(170,2,40),Color.RGB(255,224,46)];
var i,a1;
for(i=0;i<20;i++){
a1="Symbol"+(i);
a1 = eval(a1);
if(a1!=null){
vSymbols.push([a1]);
setCursorLabelName(vSymbols[cntr] + " \% Return: ", cntr);
setDefaultBarFgColor(ClrArr[cntr], cntr);
cntr++;
}
}
if(vSymbols.length==1) setCursorLabelName("Add Symbols",1);
else setStudyTitle("\% Performance " + vSymbols[0] + " vs. ");
addBand(0, PS_SOLID, 2, Color.grey, "0");
b = new Array(vSymbols.length);
vBase = new Array(vSymbols.length);
for (i = 0; i < vSymbols.length; ++i) {
vBase[i] = 100;
}
adj();
vLoaded = true;
vCalcStart = false;
}
if (getBarState() == BARSTATE_NEWBAR) {
if(vSymbols.length>1){
for (cntr = 0; cntr < vSymbols.length; ++cntr) {
if (vSymbols[cntr] != null) {
var vSym = vSymbols[cntr]+"";
var p0 = close(0,vSym);
if (!vCalcStart) {
var p1 = open(-1,vSym);
} else {
var p1 = close(-1,vSym);
}
if (p0 != null && p1 != null) {
var tReturn = ret_calc(p0, p1);
vBase[cntr] += (vBase[cntr] * tReturn);
}
}
}
}
vCalcStart = true;
adj();
}
return b;
}
function adj() {
var cntr=0;
for(cntr = 0; cntr < vSymbols.length; ++cntr) {
b[cntr] = (vBase[cntr] - 100);
}
}
function ret_calc(pNew,pOld){
var r = ((pNew-pOld)/pOld);
return r;
}
Last edited by waynecd; 08-03-2013, 06:26 PM.
Comment