Announcement

Collapse
No announcement yet.

Prices returned by close() skip every other bar

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

  • Prices returned by close() skip every other bar

    Hi,

    I'm trying to get all the closing price bars for the current day, and I'm using the following script:

    Code:
    function main(){
        var firstIndexOfDay = getFirstBarIndexOfDay( new Date() ); 
            
         if ( getCurrentBarIndex() >= firstIndexOfDay )   
                        debugPrintln(getCurrentBarIndex() + " : " + close(getCurrentBarIndex())); 
    }
    Close() is returning the closing price of every other bar, and I'm not sure why. Using getInterval() I see that the interval is correct. Please help!!!

    Thanks in advance,
    Norm

  • #2
    Norm
    Actually what you are getting is the closing price of n bars back from each bar being processed based on the bar index that you are passing to the close() function. In other words when the efs engine is processing bar index -3 you are requesting the close of 3 bars back relative to that one ie the close at absolute bar index -6.
    See this and this thread on similar issues for more detailed explanations
    As to your problem just replace close(getCurrentBarIndex()) with close(0)
    Alex


    Originally posted by nleitman View Post
    Hi,

    I'm trying to get all the closing price bars for the current day, and I'm using the following script:

    Code:
    function main(){
        var firstIndexOfDay = getFirstBarIndexOfDay( new Date() ); 
            
         if ( getCurrentBarIndex() >= firstIndexOfDay )   
                        debugPrintln(getCurrentBarIndex() + " : " + close(getCurrentBarIndex())); 
    }
    Close() is returning the closing price of every other bar, and I'm not sure why. Using getInterval() I see that the interval is correct. Please help!!!

    Thanks in advance,
    Norm

    Comment


    • #3
      That makes sense, thank you so much. It works as I expect now!

      Norm

      Comment


      • #4
        Norm
        You are welcome
        Alex


        Originally posted by nleitman View Post
        That makes sense, thank you so much. It works as I expect now!

        Norm

        Comment

        Working...
        X