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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        57 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        78 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        39 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        101 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        61 views
        0 likes
        Last Post PaulMohn  
        Working...
        X