Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Still fuzzy about different methods of getting value ...

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

    Still fuzzy about different methods of getting value ...

    I'm still a little confused as to what the differences are and when its best to use which among the following ...

    Close[barIndex]
    Bars.GetClose(barIndex)
    Close.GetValueAt(barIndex)

    Can anyone shed some light please?
    Thanks!

    #2
    Hello,

    Thank you for the question.

    The first syntax you had provided:

    Close[barIndex]

    Would actually be "BarsAgo" instead of a barIndex. This uses a number of BarsAgo or bars from the current bar. You can think of this going backwards in time from the current bar.


    The other two options are generally used when you have logic outside of OnBarUpdate like in OnRender for example.

    Because the Close and other properties like CurrentBar can be out of sync when you are using methods like OnRender, you would use a specific Index of a bar to get its value instead. In this case we are going left to right or forward in time because index 0 is the left most bar.

    The major difference in the methods provided is that the BarsAgo goes right to left, the Index goes left to right.
    The specific use would be determined by where in the script the logic is, OnBarUpdate you would likely not need to use the second and third items you provided. Outside of OnBarUpdate and likely only the second and third options would be viable.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Gerik, Today, 09:40 AM
    2 responses
    7 views
    0 likes
    Last Post Gerik
    by Gerik
     
    Started by RookieTrader, Today, 09:37 AM
    2 responses
    11 views
    0 likes
    Last Post RookieTrader  
    Started by alifarahani, Today, 09:40 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by KennyK, 05-29-2017, 02:02 AM
    3 responses
    1,285 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by AttiM, 02-14-2024, 05:20 PM
    11 responses
    186 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X