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

AddDataSeries - creating error on custom bar type

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

    AddDataSeries - creating error on custom bar type

    Hello..

    I am implementing AddDataSeries as follows in the State==State.Configure of the OnChangeStateEvent:

    _DoubleBarPeriod = 2 * Bars.BarsPeriod.Value;
    BarsPeriodType bt = this.Bars.BarsPeriod.BarsPeriodType;

    AddDataSeries(bt, _DoubleBarPeriod);
    When I cnage the bar type to either a native NT8 bar type (ie Range, Renko, Minute) it works fine. I also dont have an issue changing the bar type to a custome bar type with the exception of one cutome bar type - the one I created.

    When I use the indicator with my custom bar type, I receive the following error -

    <IndicatorName.' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load ….
    When this occurs, the indicator that has the secondary dataseries does not plot, however, my other indicators continue to plot and the custome bartype still functions.


    #2
    Hello jeliner,

    Thank you for your post.

    In this situation, all I can suggest is to use AddDataSeries as the help guide suggests or to avoid using variables and hard code the values. The error you are showing is related to the AddDataSeries used and not having the series needed load correctly. We do mention this in the help guide along with a general error you may receive however you are not limited to only this error in these use cases.


    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.
    There are quite a few areas or use cases which will fail when using variables with this AddDataSeries so this, in general, is not suggested.

    There are also specific methods to access certain BarsTypes such as Renko which does not use AddDataSeries. AddRenko would be used to add Renko data from the standard Renko bars type: https://ninjatrader.com/support/help...s/addrenko.htm

    In the AddDataSeries page there is an example of calling custom bars types which you can see here:

    Code:
    Tips
    2.  You can add a custom [URL="https://ninjatrader.com/support/helpGuides/nt8/en-us/bars_type.htm"]BarsType[/URL] which is installed on your system by casting the registered enum value for that BarsPeriodType.  For example: AddDataSeries((BarsPeriodType)14, 10);
    
    3. You can specify optional [URL="https://ninjatrader.com/support/helpGuides/nt8/en-us/barsperiod.htm"]BarsPeriod[/URL] values (such as [URL="https://ninjatrader.com/support/helpGuides/nt8/en-us/optimization_fitness_value.htm"]Value2[/URL]) of a custom BarsType in the BarsPeriod object initializer.  For example: AddDataSeries(new BarsPeriod() { BarsPeriodType = (BarsPeriodType)14, Value = 10, Value2 = 20});
    You can use the following public script to find BarsType ids: https://ninjatraderecosystem.com/use...pe-identifier/

    At this time there would be no suggested way to accomplish what you have displayed while using runtime variables, all value would need to be hard coded.

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for the help.

      I have hardcoded the values has you have suggested and I still received the same error. I have implemented the change below:

      AddDataSeries(new BarsPeriod() { BarsPeriodType =(BarsPeriodType)1971, Value = 8, Value2 = 4 });
      I also tried the following, which also produced the same error
      AddDataSeries((BarsPeriodType)1971, 8);
      I went down the path of creating a custom bar type because of the discussion I had with ChelseaB about hardcoding values into the AddDataSeries method. See Conversation at the following link … https://ninjatrader.com/support/foru...n-an-indicator

      Let me explain what I am trying to avoid doing. On my day trading workspace, I have 12 markets I watch on 12 charts across 2 monitors. Each chart has 4 tabs, containing different time frames of the same symbol. For this single workspace, If I hardcode the values, I will need 48 versions of this indicator for a single workspace. I have a similar setup for a currency workspace containing six charts of futures on one monitor and six forex and I have a third workspace with metals, energies. and some grains that I position trade. To do as you are suggesting, I will need 144 versions of this indicator. This is not a very efficient approach.

      Before I go down the path of creating 144 versions of this indicator for each market, I need to at least get it to work on one. I have hardcoded the values as shown above. I know for certain the registered ID of the bar type is 1971, because I created it .. and it prints that number in the output window with the utilities script you linked.
      Last edited by jeliner; 02-08-2019, 01:39 PM.

      Comment


        #4
        After much experimentation … the following worked ...

        AddRenko(Instrument.ToString(), Bars.BarsPeriod.Value, MarketDataType.Last);
        My intent was not to create a custom Rinko bar, but I guess that's what I did, interesting. I am also glad, although not recommended, I was able to pass variables into the function. I was really dreading creating 144 versions of this indicator.

        Thanks for the help

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cls71, Today, 04:45 AM
        0 responses
        1 view
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        213 views
        1 like
        Last Post PaulMohn  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        4 responses
        544 views
        0 likes
        Last Post PaulMohn  
        Started by GLFX005, Today, 03:23 AM
        0 responses
        3 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        12 views
        0 likes
        Last Post XXtrader  
        Working...
        X