Announcement

Collapse
No announcement yet.

var b = close(0, 1, vSym); is this syntax correct?

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

  • var b = close(0, 1, vSym); is this syntax correct?

    The second parameter for close() should be a negative # per the knowledgebase yet the efs study below has a positive 1 as a second parameter and it plots. So, since close() does not compute one bar into the future, what does the second parmeter represent in:
    PHP Code:
    close(01vSym); 
    Thanks

    Wayne

    The RelativeStrengthRatio.efs script found at: http://share.esignal.com/download.js...engthRatio.efs
    has "var b = close(0, 1, vSym);" in line 38.

    The efs KnowledgeBase has the following for close():
    close([nRelativeOffset] [, nNumBars [, Symbol ] ])

    nRelativeOffset: Offset to bar. 0 is most recent bar, -1 is next bar, etc.
    nNumBars: Number of bars to retrieve (a negative number)
    Symbol: The symbol to retrieve data for.

    Examples:

    close(-1); gets the next-to-last close for the current symbol
    close(0, "IBM"); gets the most recent close for IBM
    close(0, -10, "INTC"); gets the last 10 closes for INTC and places them in an array

  • #2
    Re: var b = close(0, 1, vSym); is this syntax correct?

    waynecd
    When the NumBars parameter is set to 1 it makes no difference if the number is positive or negative because you are creating an array of 1 element ie the value at the defined bar index
    Run the enclosed code and the difference between a positive or negative NumBars should be self explanatory once you check the values returned to the Formula Output Window
    Alex

    PHP Code:
    function main(){
        if(
    isLastBarOnChart()){
            
    debugPrintln("line3   "+close(-10,1));
            
    debugPrintln("line4   "+close(-10,-1));
            
    debugPrintln("line5   "+close(-10,2));
            
    debugPrintln("line6   "+close(-10,-2));
        }


    Originally posted by waynecd
    The second parameter for close() should be a negative # per the knowledgebase yet the efs study below has a positive 1 as a second parameter and it plots. So, since close() does not compute one bar into the future, what does the second parmeter represent in:
    PHP Code:
    close(01vSym); 
    Thanks

    Wayne

    The RelativeStrengthRatio.efs script found at: http://share.esignal.com/download.js...engthRatio.efs
    has "var b = close(0, 1, vSym);" in line 38.

    The efs KnowledgeBase has the following for close():

    Comment


    • #3
      Alex,

      I see it. Such an easy test to figure this out.

      The sign (+ or -) just defines the direction in which the closes are put into the series. A positive parameter moves forward in time/bars closer to the current bar and a negative moves backwards in time/bars farther away from the current bar.

      Thanks

      Wayne
      Last edited by waynecd; 09-01-2009, 11:00 AM.

      Comment


      • #4
        waynecd

        The sign (+ or -) just defines the direction in which the closes are put into the series.
        When using the close() function with the legacy syntax it actually generates an array and not a series
        Alex


        Originally posted by waynecd
        Alex,

        I see it. Such an easy test to figure this out.

        The sign (+ or -) just defines the direction in which the closes are put into the series. A positive parameter moves forward in time/bars closer to the current bar and a negative moves backwards in time/bars farther away from the current bar.

        Thanks

        Wayne

        Comment

        Working...
        X