Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using ChartBars to reference another chart

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

    Using ChartBars to reference another chart

    Hello,

    I have a 1 min chart that references a 100 tick chart using
    AddDataSeries("NQ 03-25", Data.BarsPeriodType.Tick, 100, Data.MarketDataType.Last);

    Based on some search results, it appears as though if I want the high of the next-to-last completed bar on the 100 tick chart, I could use this:
    if ChartBars[1].High[1] > some calculation...

    But when I try it, I get CS0021 "Cannot apply indexing with [] to an expression of type 'ChartBars'.

    I'm probably missing something obvious here, but I can't find any examples of using ChartBars to reference another chart's bar properties anywhere other than that one above in bold.

    Any help would be much appreciated.

    Thank you!


    #2
    Hello LunaKai,

    ChartBars refers to the primary series, its not something that is indexed. You can use Highs[1][0] to get a secondary series value that you added in code. The 1 would be the bars in progress for the series you wanted to access and 0 is 0 bars ago.

    Comment


      #3
      Brilliant, thank you!

      Comment


        #4
        Hi, i have another question... if want to use multiple instrument data. for example setting the strategy up on an MNQ chart, but using also the MES data, how can i efficiantly call the MES data always using the latest contract dates? I have this, at the moment

        AddDataSeries("MES 03-25", Data.BarsPeriodType.Minute, 2);

        it works, but i don't want to change the dates manually

        Comment


          #5
          Hello konganda,

          With secondary series you will need to change the dates, there is no way to inherit the current contract date as a variable for secondary series.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          20 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          30 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          47 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          38 views
          0 likes
          Last Post CarlTrading  
          Working...
          X