Announcement

Collapse
No announcement yet.

variable as a series

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • variable as a series

    Hello,

    How do you make a variable a series so you can access historical values with .getValue?

    -Mike

  • #2
    Hello Mike,
    The following series example code is also included as a notepad attachment:

    function preMain(){
    setPriceStudy(true);
    setStudyTitle("Forum Series Example")
    }

    var xCloseMinusUBB = null; // Global variable
    var xCloseMinusLBB = null; // Global variable
    var xHighestClose = null; // Global variable

    function main(){
    if(getBarState() == BARSTATE_ALLBARS){
    var nCalcUBB = null;
    var nCalcLBB = null;
    var nHighestClose = null;
    xCloseMinusUBB = efsInternal("CalcCloseMinusUBB") // No function parameters
    xCloseMinusLBB = efsInternal("CalcCloseMinusLBB", close(), lowerBB(20, 2)); // Pass 2 function parameters
    xHighestClose = highest(10, close()); // Use eSignal's series objects.
    }
    nCalcUBB = xCloseMinusUBB.getValue(0);
    nCalcLBB = xCloseMinusLBB.getValue(-3);
    nHighestClose = xHighestClose.getValue(-5);

    if(getBarState() != BARSTATE_CURRENTBAR)
    debugPrintln(getCurrentBarIndex() + "\t" + close(0) + "\t" + upperBB(20, 2, 0) + "\t" +
    lowerBB(20, 2, 0) + "\t" + nCalcUBB + "\t" + nCalcLBB + "\t" + nHighestClose);
    return;
    }

    function CalcCloseMinusUBB(){
    return close(0) - upperBB(20, 2, 0)
    }

    function CalcCloseMinusLBB(nPrice, nLBB){
    return nPrice.getValue(0) - nLBB.getValue(0);
    }

    LetUsLearn
    Attached Files

    Comment

    Working...
    X