Announcement

Collapse
No announcement yet.

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.




    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    156 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    90 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    140 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    130 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X