Daily Percent Comparison

ICE Data Services -


DailyPercentComp.efs  EFSLibrary - Discussion Board
  

File Name: DailyPercentComp.efs


Description:
Daily Percent Comparison


Formula Parameters:
Symbol 1 Color : Green
Symbol 2 Color : Red
Symbol 3 Color : Blue
Symbol 4 Color : Brown
Symbol 2 : not defined
Symbol 3 : not defined
Symbol 4 : not defined
Lines Thickness : 2

Notes:
This study will compare the daily percentage change in price for up to 4 symbols.
The percent change is calculated from the open of the daily chart interval to the
last traded price.


Download File:
DailyPercentComp.efs




EFS Code:






/*********************************Provided By:      eSignal (Copyright c eSignal), a division of Interactive Data     Corporation. 2008. All rights reserved. This sample eSignal     Formula Script (EFS) is for educational purposes only and may be     modified and saved under a new file name.  eSignal is not responsible    for the functionality once modified.  eSignal reserves the right     to modify and overwrite this EFS file with each new release.Description:            Daily Percent Comparison    Version:            1.0  01/20/2009Formula Parameters:                     Default:    Symbol 1 Color                      Green    Symbol 2 Color                      Red    Symbol 3 Color                      Blue    Symbol 4 Color                      Brown    Symbol 2                            not defined    Symbol 3                            not defined    Symbol 4                            not defined    Lines Thickness                     2Notes:    This study will compare the daily percentage change in price for up to 4 symbols.    The percent change is calculated from the open of the daily chart interval to the     last traded price.**********************************/var fpArray = new Array();var bInit = false;function preMain() {    setPriceStudy(false);    setShowCursorLabel(true);    setShowTitleParameters(false);    setIntervalsBackfill(true);    setStudyTitle("Daily Percent Comparison");    setCursorLabelName(getSymbol(), 0);    setPlotType(PLOTTYPE_LINE, 0);     setDefaultBarThickness(2, 0);    setDefaultBarFgColor(Color.green, 0);    addBand(0, PS_SOLID, 1, Color.grey);    setPlotType(PLOTTYPE_LINE, 1);        setPlotType(PLOTTYPE_LINE, 2);        setPlotType(PLOTTYPE_LINE, 3);           askForInput();    var x=0;    fpArray[x] = new FunctionParameter("LineColor1", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Symbol 1 Color");        setDefault(Color.green);    }        fpArray[x] = new FunctionParameter("LineColor2", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Symbol 2 Color");        setDefault(Color.red);    }        fpArray[x] = new FunctionParameter("LineColor3", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Symbol 3 Color");        setDefault(Color.blue);    }        fpArray[x] = new FunctionParameter("LineColor4", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Symbol 4 Color");        setDefault(Color.brown);    }        fpArray[x] = new FunctionParameter("Symbol2", FunctionParameter.STRING);    with(fpArray[x++]){        setName("Symbol 2");        setDefault("");    }        fpArray[x] = new FunctionParameter("Symbol3", FunctionParameter.STRING);    with(fpArray[x++]){        setName("Symbol 3");        setDefault("");    }        fpArray[x] = new FunctionParameter("Symbol4", FunctionParameter.STRING);    with(fpArray[x++]){        setName("Symbol 4");        setDefault("");    }        fpArray[x] = new FunctionParameter("Thickness", FunctionParameter.NUMBER);	with(fpArray[x++]){        setName("Lines Thickness");        setLowerLimit(1);		        setDefault(2);    }}var nOpenSym1 = null;var nOpenSym2 = null;var nOpenSym3 = null;var nOpenSym4 = null;var aSymbols = new Array(4);var aOpen = new Array(4);var nSymbolCount = 0;var bError = false;function main(Symbol2, Symbol3, Symbol4, LineColor1,            LineColor2, LineColor3, LineColor4, Thickness) {var aReturnDPC = new Array();var nCurrentClose = 0;var i = 0;var sTitle = "DPC "+getSymbol();    if (bError == true) return;    if ( bInit == false ) {         setCursorLabelName(getSymbol(), 0);        setDefaultBarFgColor(LineColor1, 0);        setDefaultBarFgColor(LineColor2, 1);        setDefaultBarFgColor(LineColor3, 2);        setDefaultBarFgColor(LineColor4, 3);        for (i = 0; i <= 3; i++) {            setDefaultBarThickness(Thickness, i);            aSymbols[i] = "";            aOpen[i] = 0;        }        nSymbolCount = 0;        aSymbols[nSymbolCount] = getSymbol();        if (Symbol2 != "") {            nSymbolCount++;            aSymbols[nSymbolCount] = Symbol2;            sTitle = sTitle+" | "+aSymbols[nSymbolCount];        }            if (Symbol3 != "")  {            nSymbolCount++;            aSymbols[nSymbolCount] = Symbol3;            sTitle = sTitle+" | "+aSymbols[nSymbolCount];        }            if (Symbol4 != "")  {            nSymbolCount++;            aSymbols[nSymbolCount] = Symbol4;            sTitle = sTitle+" | "+aSymbols[nSymbolCount];        }            setStudyTitle(sTitle+" |");        bInit = true;     }     if (isIntraday() == false && bError == false) {        setStudyTitle("This formula requires an intraday interval.")            bError == true;        return;    }        if (day(0) != day(-1)) {        for (i = 0; i <= nSymbolCount; i++) {            aOpen[i] = open(0, sym(aSymbols[i]+",D"));        }    }    if (aOpen[0] != 0 && aOpen[0] != null) {        for (i = 0; i <= nSymbolCount; i++) {            if (i == 0) aReturnDPC[i] = Ret_Calc(close(0), aOpen[i]);            else aReturnDPC[i] = Ret_Calc(close(0, sym(aSymbols[i])), aOpen[i]);            setCursorLabelName(aSymbols[i], i);        }    } else return;    return aReturnDPC; }function Ret_Calc(pNew, pOld){var nRes = 0;    nRes = ((pNew - pOld) / pOld) * 100;    return nRes;}