Announcement

Collapse
No announcement yet.

Daily Percent Comparison

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Daily Percent Comparison

    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:
    PHP 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/2009

    Formula 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                     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.
    **********************************/

    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_LINE0); 
        
    setDefaultBarThickness(20);
        
    setDefaultBarFgColor(Color.green0);
        
    addBand(0PS_SOLID1Color.grey);
        
    setPlotType(PLOTTYPE_LINE1);    
        
    setPlotType(PLOTTYPE_LINE2);    
        
    setPlotType(PLOTTYPE_LINE3);    
       
        
    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(Symbol2Symbol3Symbol4LineColor1,
                
    LineColor2LineColor3LineColor4Thickness) {
    var 
    aReturnDPC = new Array();
    var 
    nCurrentClose 0;
    var 
    0;
    var 
    sTitle "DPC "+getSymbol();
        if (
    bError == true) return;
        if ( 
    bInit == false ) { 
            
    setCursorLabelName(getSymbol(), 0);
            
    setDefaultBarFgColor(LineColor10);
            
    setDefaultBarFgColor(LineColor21);
            
    setDefaultBarFgColor(LineColor32);
            
    setDefaultBarFgColor(LineColor43);
            for (
    0<= 3i++) {
                
    setDefaultBarThickness(Thicknessi);
                
    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 (
    0<= nSymbolCounti++) {
                
    aOpen[i] = open(0sym(aSymbols[i]+",D"));
            }
        }

        if (
    aOpen[0] != && aOpen[0] != null) {
            for (
    0<= nSymbolCounti++) {
                if (
    == 0aReturnDPC[i] = Ret_Calc(close(0), aOpen[i]);
                else 
    aReturnDPC[i] = Ret_Calc(close(0sym(aSymbols[i])), aOpen[i]);
                
    setCursorLabelName(aSymbols[i], i);
            }
        } else return;
        return 
    aReturnDPC
    }

    function 
    Ret_Calc(pNewpOld){
    var 
    nRes 0;
        
    nRes = ((pNew pOld) / pOld) * 100;
        return 
    nRes;

Working...
X