Announcement

Collapse
No announcement yet.

PerformanceComp.efs

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

  • PerformanceComp.efs

    File Name: PerformanceComp.efs

    Description:
    Compare up to 3 symbols on a % performance basis as a non-price study.

    Formula Parameters:
    Symbol1: Any valid symbol
    Symbol2: Any valid symbol

    Notes:
    Must apply a time template that is not in dynamic mode to establish a specific starting point. This formula will not display useful results if your time template is in dynamic mode. For intra-day chart intervals, it is recommended to set the start/end times in your time template to the market’s open and close times.

    Download File:
    PerformanceComp.efs




    EFS Code:
    PHP Code:
    /*************************************************
    Provided By : eSignal. (c) Copyright 2003
    *************************************************/
    addBand(0PS_SOLID2Color.grey"0");

    var 
    vLoaded false;
    var 
    cSym "";
    function 
    preMain() {
        if (
    vLoaded == false) {    
            
    setStudyTitle("\% Performance  ... Add Symbol(s)");
            
    setCursorLabelName(""0);
            
    setCursorLabelName("Add Symbol"1);
            
    setCursorLabelName("Add Symbol"2);
            
    setDefaultBarFgColor(Color.blue0);
            
    setDefaultBarFgColor(Color.red1);
            
    setDefaultBarFgColor(Color.green2);
        } else {
            if (
    vSymbols[1] != null || vSymbols[2] != null) {
                
    setStudyTitle("\% Performance " cSym " vs. ");
            }
            
    setCursorLabelName(cSym " \% Return"0);
            if (
    vSymbols[1] != null) {
                
    setCursorLabelName(vSymbols[1] + " \% Return"1);
            }
            if (
    vSymbols[2] != null) {
                
    setCursorLabelName(vSymbols[2] + " \% Return"2);
            }
        }
    }

    var 
    vSymbols = new Array(3);

    var 
    vBase = new Array(3);
    var 
    = new Array(3);
    for (
    03; ++i) {
        
    vBase[i] = 100;
    }

    var 
    vCalcStart false;

    function 
    adj() {
        for(
    cntr 0cntr 3; ++cntr) {
            
    b[cntr] = (vBase[cntr] - 100);
        }
    }

    function 
    ret_calc(pNew,pOld){
        var 
    = ((pNew-pOld)/pOld);
        return 
    r;
    }

    function 
    main(Symbol1Symbol2) {
        if (
    vLoaded == false) {
            
    cSym getSymbol();
            
    vSymbols[0] = cSym;
            for (
    cntr 1cntr 3; ++cntr) {
                if (eval(
    "Symbol" cntr) != null) {
                    
    vSymbols[cntr] = eval("Symbol" cntr);
                }
            }
            for (
    03; ++i) {
                
    vBase[i] = 100;
            }
            
    adj();
            
    vLoaded true;
            
    vCalcStart false;
            
    preMain();
        }

        if (
    getBarState() == BARSTATE_NEWBAR) {
            for (
    cntr 0cntr 3; ++cntr) {
                if (
    vSymbols[cntr] != null) {
                    var 
    p0 close(01vSymbols[cntr]);
                    if (
    vCalcStart == false) {
                        var 
    p1 open(-11vSymbols[cntr]);
                    } else {
                        var 
    p1 close(-11vSymbols[cntr]);
                    }
                    if (
    p0 != null && p1 != null) {
                        var 
    tReturn ret_calc(p0p1);
                        
    vBase[cntr] += (vBase[cntr] * tReturn);
                    }
                }
            }
            
    vCalcStart true;
            
    adj();
        }
        return 
    b;

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation
Working...
X