Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Any different between ChartBars.Bars.GetXYZ() and XYZ[0][0]?

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

    Any different between ChartBars.Bars.GetXYZ() and XYZ[0][0]?

    there are:
    Code:
    ChartBars.Bars.GetOpen()
    ChartBars.Bars.GetHigh()
    ChartBars.Bars.GetLow()
    ChartBars.Bars.GetClose()
    ChartBars.Bars.GetTime()
    ChartBars.Bars.Volume()
    and

    Code:
    Closes[0]
    Highs[0]
    Lows[0]
    Opens[0]
    Times[0]
    Volumes[0]
    Is there any difference (or can theorically raise in our scripts in some conditions) if we use one or another? or they are absolutely same/replacements and we can use one or another?

    for example, `ChartBars.Bars.GetClose(ChartBars.Bars.Count-1)` and `Closes[0][0]`

    #2
    Hello TazoTodua,

    Thank you for the post.

    Yes, in this case, there is a difference between the syntax you have shown. One is a method that uses a direct index to retrieve a value from the primary series. The second syntax is a variable for the series its self which you can then use the BarsAgo system with. The BarsAgo system and Index system are inverse meaning they represent traversing the data in opposite directions.

    You can use both in your scripts and they do generally serve the same purpose for retrieving data however the Get methods are specifically used in out of event-driven context such as OnRender where you cannot use the BarsAgo concepts. The BarsAgo is generally used inside of the event-driven context like OnBarUpdate where the relation to the current processing bar matters, I.E. 5 bars from right now in the past [5 BarsAgo].

    They are able to reach the same general values when using opposite inputs, but each serves its own specific purpose.

    I look forward to being of further assistance.




    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cre8able, Yesterday, 04:22 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by stafe, 04-15-2024, 08:34 PM
    5 responses
    28 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by StrongLikeBull, Yesterday, 04:05 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Mestor, 03-10-2023, 01:50 AM
    14 responses
    375 views
    0 likes
    Last Post z.franck  
    Started by molecool, 10-09-2017, 10:48 AM
    5 responses
    1,621 views
    0 likes
    Last Post trader-ap  
    Working...
    X