• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error when loading Unirenko additional bar period NT8

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

    Error when loading Unirenko additional bar period NT8

    Hello,

    I'm getting the following error when I attempt to load an additional Unirenko bar period in NT8:

    All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load CL 01-19 Nymex: UniR T15R45O2

    I'm using the following code:

    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Minute, 1); // works
    BarsPeriod largePeriod = new BarsPeriod()
    {
    BarsPeriodType = (BarsPeriodType)501,
    BaseBarsPeriodType = BarsPeriodType.Minute,
    BaseBarsPeriodValue = LargeBarPeriodBaseValue,
    Value = LargeBarPeriodValue,
    Value2 = LargeBarPeriodValue2,
    };
    AddDataSeries(largePeriod); // data load error
    }


    Adding the minute period type bars works, but the Unirenko fails. This is in an indicator and not a strategy. I'm aware that a hosting strategy needs to add the same periods as embedded indicators; this is not that situation.

    LargeBarPeriodBaseValue, LargeBarPeriodValue, and LargeBarPeriodValue2 are user configurable parameters.They're initialized during the State.SetDefaults state clause but are can be modified via indicator properties.

    Thanks.

    #2
    Hello silverm3170,

    Thank you for the post.

    I wanted to check if you remove all variables does this work? In general, using variables with AddDataSeries is known to fail and is documented in the help guide to avoid. If you hard code the values here, then completely remove the instance and reapply it do you still get the same error?

    Is this the unirenko from the user app share? Can you provide a link to the version you downloaded for me to test as well?


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      I hard coded that values instead of using the LargeBarPeriod* variables, and now I don't see the error but I also don't see any BarsInProgress in OnBarUpdate other than 0 (main chart time frame) and 1 (minute bar type). I don't recall where I got the Unrenko bar type, I think it may have been from Futures.io. I'll see if there's an equivalent in the user app share and try that as well before pointing you to the version to test.

      How does AddDataSeries know if a parameter is hard coded or passed in as a variable? I want to be able to modify the bar parameters based on instrument and I can't do that if I have to hard code it.

      Thanks,
      Silverm3170

      Comment


        #4
        Hello silverm3170,

        Yes if you can identify the version used, I could try it as well to check the result.

        In regard to AddDataSeries, it does not know and that is part of the problem. The specific comment we provide on this is the following:

        Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.
        The problem is that user variables are not reliably available at the times where AddDataSeries logic is being run which can generate errors. Hardcoding the value is really the only way to avoid this limitation of this method.

        This alone does not seem to correct the problem for you but it does seem to have moved you one step forward. The BarsInProgress not being run could be related to data availability, you may try requesting the timeframe in a chart with the unirenko bars type selected to make sure the bars build. Once you do this, retest and see if that makes any difference, if not we could explore this further once I know the version of the bars type being used.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Jesse I switched to using the Unirenko from the link you provided. I then modified my code as follows:

          BarsPeriod largePeriod = new BarsPeriod()
          {
          BarsPeriodType = (BarsPeriodType)2018,
          BaseBarsPeriodType = BarsPeriodType.Minute,
          BaseBarsPeriodValue = 2,
          Value = 15,
          Value2 = 45,
          };
          AddDataSeries(largePeriod);

          I also tried it with BarsPeriodType.Tick as that's the base type in the bar's .cs file. I still don't see BarsInProgress = 2 in OnBarUpdate either way (I'm still adding the 1 minute period bar series).

          I switched to using this Unirenko for the chart's base type as well. I recompiled my indicator; I'm assuming that's sufficient to compile the new Unirenko file too. The chart's base time frame Unirenko bars are displaying properly.

          Comment


            #6
            Hello silverm3170,

            Thank you for the additional details.

            I tried this on my end and see the print working. Just to confirm this is not simply a problem in your test, can you try the attached indicator to see what prints out?
            On my end I am seeing output like the following:

            Code:
            0
            1
            0
            1
            0
            1
            Have you also restarted the platform as a test? This would just be in case using the previous test which was erroring had some lasting effect.



            I look forward to being of further assistance.

            Attached Files
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks for the file Jesse. Your indcator works, and adding a third bar period bumps up the BarsInProgress to 2. I'll need to figure what else is causing the third bar period to not update in my case.

              Comment


                #8
                Jesse I figured out the problem. I was using user input bools to conditionally add the periods. As with the bar configuration params, it looks like these can't be relied on during State.Config. Once I made the AddDataSeries unconditional the third set of BarsInProgress showed up. Thanks for your help.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by ajsdnyyrr1234DDf, Today, 09:39 AM
                2 responses
                12 views
                0 likes
                Last Post ajsdnyyrr1234DDf  
                Started by Delerium, Today, 10:03 AM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_JoshG  
                Started by pjsmith, Today, 09:54 AM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_PatrickG  
                Started by afoschini, Today, 09:18 AM
                2 responses
                6 views
                0 likes
                Last Post afoschini  
                Started by rexsole, Today, 08:02 AM
                1 response
                17 views
                0 likes
                Last Post NinjaTrader_PatrickG  
                Working...
                X