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, 02: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]);

    https://ninjatrader.com/support/help...currentbar.htm
    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 WHICKED, Yesterday, 11:12 PM
        0 responses
        2 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by AdeptistJune, Yesterday, 08:08 PM
        1 response
        6 views
        0 likes
        Last Post bltdavid  
        Started by GKbowen, Yesterday, 04:03 PM
        3 responses
        12 views
        0 likes
        Last Post bltdavid  
        Started by bojim, Yesterday, 08:35 PM
        0 responses
        3 views
        0 likes
        Last Post bojim
        by bojim
         
        Started by jamestrader21x, Yesterday, 07:53 AM
        8 responses
        33 views
        0 likes
        Last Post NinjaTrader_Kate  
        Working...
        X