Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        23 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        21 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X