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 NullPointStrategies, Today, 05:17 AM
          0 responses
          36 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X