Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

COT data before chart time

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

    COT data before chart time

    Lets say the chart shows the last 100 days. The COT Indicator would then only provide data for the last 100 days. However, I need to access data *before*. How can I do it?

    For example this doesnt work if "CurrentBar == 0", because of "Time[10]" gives an index out of bounds.
    Code:
    cot = new CotReport { ReportType = CotReportType.Futures, Field = CotReportField.CommercialShort };
    Cot.Calculate(Instrument.MasterInstrument.Name, Time[10])
    Last edited by Bobin; 11-28-2021, 03:56 PM.

    #2
    Hello Bobin,

    Scripts are only able to work with the data provided from the data series.

    You can wait until there are 10 bars before calling 10 bars ago.

    if (CurrentBar < 11)
    return;

    Print(Time[10]);

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,
      thanks for your answer.
      I am not sure, but I think the COT indicator does not really need the data series because it is completely different data.
      The problem is I need very old COT data and would need to load several years. This would be a high overhead, because it would also read so much data from the main data series which (in theory) would not be needed by the COT indicator.
      Furthermore, I actually do not need to draw the COT indicator, I just need its values.

      Comment


        #4
        Hello Bobin,

        To answer your original question about loading data, if you needed more data than the days you specified then you would have to change the 100 days to load more data. There is not a way around that when working with indicators. Indicators process based on the data loaded and that would be the requirement to look back for any period of time.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X