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

Setting BarsToLoad in AddDataSeries

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

    Setting BarsToLoad in AddDataSeries

    I am loading a 1440 minute as a second series in one of my indicators. In order for the indicator to do proper calculations it needs 30 days worth of the daily series. What I don't want to do is having to constantly be forced to use 1-min charts with 30 days worth of data.

    So I'm attempting to replace this call...

    AddDataSeries(BarsPeriodType.Minute, 1440); // 2nd daily series

    with this:

    AddDataSeries(Instruments[0].MasterInstrument.Name, new
    BarsPeriod() { BarsPeriodType = (BarsPeriodType)5, Value = 1440 }, 30, TradingHours.Name, null);

    Unfortunately I'm getting no data back and the second series always has a length of 0 as reported by OnBarsUpdate():

    Print(CurrentBars[1]);

    Code:
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0

    I understand this is somewhat of a cryptic call but solving this would save me a lot of time as I'm using this indicator in the context of a strategy running on 1-min series.

    FWIW - adding this convenience method would help:

    AddDataSeries(string instrumentName, BarsPeriodType periodType, int period, int barsToLoad)
    Last edited by molecool; 11-18-2017, 10:05 AM.

    #2
    Hello,

    Thank you for your note.

    TradingHours.Name is not known in state.configure. A clue can be seen on the log tab.

    If you modify your AddDataSeries to,

    AddDataSeries("ES 12-17", new BarsPeriod() { BarsPeriodType = (BarsPeriodType)4, Value = 1440 }, 60,"US Equities ETH" , null);

    Do you see prints as expected?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan, that actually worked and Instruments[0].MasterInstrument.Name was still available.

      A suggestion however: Launching this indicator however requires me to now set a parameter with the required session string. So I would still ask for you guys to provide a simpler override of AddDataSeries that does not require setting a session, the instrument name, etc.

      A lot of us use secondary data series and sometimes would like to be able to specify how much of that data to be loading. The method provided works but requires adding a dependency, i.e. the session name.

      Hope this makes sense.

      Originally posted by NinjaTrader_AlanP View Post
      Hello,

      Thank you for your note.

      TradingHours.Name is not known in state.configure. A clue can be seen on the log tab.

      If you modify your AddDataSeries to,

      AddDataSeries("ES 12-17", new BarsPeriod() { BarsPeriodType = (BarsPeriodType)4, Value = 1440 }, 60,"US Equities ETH" , null);

      Do you see prints as expected?

      I look forward to your reply.

      Comment


        #4
        Hello molecool,

        Thank you for your suggestion I will forward your add data series override request on as a feature request.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hey guys - I am running into an unforeseen issue. When embedding the indicator into a strategy it appears that insufficient candles of the 1440 minute series are loaded (per the AddDataSeries line discussed below placed inside the actual indicator which is currently set to 60 bars).

          Now remembering another issue I posted last weekend I was willing to bet good money that it had to do with me loading the same data series the regular way in my strategy. As you know the strategy embedding an indicator now needs to load the same data series or NT8 will throw a runtime error. I've already *****ed about that in a separate support thread but anyway, I was pretty certain that I needed to perform the loading of the 1440 minute data in the same fashion as in the indicator.

          However for some reason this does NOT in fact work. When loading the indicator alone on a chart it works as expected. But when loading it inside a strategy it does not plot anything due to it loading insufficient 1440 minute candles.


          Can you guys please test this on your end and report back? All you have to do is to create an indicator with a second 1440 minute series which loads more than what's on the chart:

          Code:
          AddDataSeries(Instruments[0].MasterInstrument.Name, new BarsPeriod() { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, Period * 2, SessionName , null);
          THEN embed that indicator into a strategy, load the 1440-min data the same way and print the count:

          Code:
          if (BarsInProgress == 1 && IsFirstTickOfBar)
          	Print(CurrentBars[1]);
          I have 20 days loaded on my chart and the counter in my indicator only gets to 12. Something's broken here...

          Comment


            #6
            Hello molecool,

            Adding the data series to the indicator and the strategy presents errors due to your add calls including user inputs, SessionName, Period. Furthermore I would be guessing where you put your add calls, configure vs data loaded.

            To avoid assumptions, if you would like us to test please upload a sample which demonstrates the behavior you describe using the following format,

            To export a NinjaScript from NinjaTrader 8 do the following:
            From the Control Center window select Tools -> Export -> NinjaScript...
            Click Add>Select the indicator>OK>Export.
            Then attach that file you saved; under My Docs>NT8>Bin>Custom>Select the downloaded .zip file.

            I look forward to your reply.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_AlanP View Post
              Hello molecool,

              Adding the data series to the indicator and the strategy presents errors due to your add calls including user inputs, SessionName, Period. Furthermore I would be guessing where you put your add calls, configure vs data loaded.
              Good thinking but actually my indicators are in fact configured in State.DataLoaded:

              Code:
              else if (State == State.DataLoaded)	{
              					LoadIndicators();
              				}
              Even if I hardcode the settings I am experiencing the same issue. And I did print them beforehand in my log to make sure they are actually present.

              Anyway, so you're telling me that this ought to be working, correct? I will go over everything one more time and if it still fails then I'll put together a test case for you guys. I assume you won't be seeing that one though until next Monday due to the long holiday, correct?

              Comment


                #8
                Hello molecool,

                With only snippets of the code I'm unable to comment on whether it should or should not work.

                We will have a limited support staff tomorrow and a regular staff friday so likley but not a guarantee you will hear back before monday.

                I look forward to your reply.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_AlanP View Post
                  Hello molecool,

                  With only snippets of the code I'm unable to comment on whether it should or should not work.

                  We will have a limited support staff tomorrow and a regular staff friday so likley but not a guarantee you will hear back before monday.

                  I look forward to your reply.
                  Okay, thanks for the update. I just wrote a test strategy and it was loading properly, so it must be something else. I keep digging :-/

                  Comment


                    #10
                    Test strategy has been sent

                    Hey guys - I was able to reproduce the problem in a test strategy by replicating the series lineup in my actual strategy. In mailed it to you already and provided instructions. If anything is unclear please let me know.

                    Comment


                      #11
                      Test Strategy

                      I'm uploading a test strategy that includes instructions. Should be self explanatory. If anyone has any input about why there are less prints with all AddSeries() calls enabled I'd be all ears. To me this looks like a possible NT8 bug.

                      Incidentally this thread should be moved to Strategy Development as this is a strategy related issue.
                      Attached Files

                      Comment


                        #12
                        Have you actually followed the instructions? See all the commented out code?

                        YOU ARE SUPPOSED TO UNCOMMENT ALL THAT AND THEN RUN IT AGAIN!

                        Have you done that? YES or NO? This has nothing to do with the friggin' output window. It's been 9 days now without a proper response on this issue.

                        Seriously guys - do I have to draw you a picture? I mean, my instructions, IF YOU TOOK THE TIME TO READ THEM, couldn't have been any clearer.

                        It looks like you are printing to the output window 2, please see attachment.

                        If you remove PrintTo = PrintTo.OutputTab2;, there should be no issue.

                        Please let us know if you need further assistance.

                        Comment


                          #13
                          Hello molecool,

                          My apologies.

                          This has been reported to development and we are waiting for a reply.

                          Thank you for your patience.
                          Alan P.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_AlanP View Post
                            Hello molecool,

                            My apologies.

                            This has been reported to development and we are waiting for a reply.

                            Thank you for your patience.
                            My patience, I'm sure you have noticed, is running a bit thin. I know it's been a long weekend and all, but nine days without anything resembling an answer?

                            I have gone out of my way to demonstrate what could easily be a NT8 bug. Is there at least an ETA until someone actually LOOKS at this issue?

                            Comment


                              #15
                              Hello molecool,

                              There is no ETA at this time. I will follow up when I have more information.

                              Thank you for your patience.
                              Alan P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by funk10101, Today, 12:02 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post funk10101  
                              Started by gravdigaz6, Yesterday, 11:40 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by MarianApalaghiei, Yesterday, 10:49 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by XXtrader, Yesterday, 11:30 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post XXtrader  
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post love2code2trade  
                              Working...
                              X