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

How to get BarsPeriodType property to pick up non-standard types

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

    How to get BarsPeriodType property to pick up non-standard types

    I have an indicator that specifies a BarsPeriodType property. All works fine, but it does not pick up any extended bar types when changed in the UI. Can this be done by specifying a typeconverter somehow?

    For example:
    Code:
            [NinjaScriptProperty]
            [Display(Name="Bar Type", Description="Bar Type", Order=2, GroupName="Parameters")]
            public BarsPeriodType BarType { get; set; }

    #2
    Hello aslane,

    This code implies you are using dynamic variables with an AddDataSeries() call which is not allowed or supported.

    May I confirm this is not being used for an AddDataSeries() call?

    Can you clarify what you mean by 'extended bar types'?
    Are you talking about classes that are extending another class?
    Are you talking about imported 3rd party bar type scripts?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      By extended bar types, I just mean user created bar types (with user specified bar period type).

      Ok, I see the doc in AddDataSeries. Not supported? That seems rather broken. Really need to add new feature request if it does not exist, as this is rather fundamental for mutli-timeframe studies. Will this work if there is a boolean property that would allow the type to be flipped between two different bar types or would that still be considered dynamic?

      Yes, I was using this to load a user configurable data series. However, if this was not the case, can this be done?

      Comment


        #4
        Hello aslane,

        It is supported to use a custom bar type with AddDataSeries(). It is not supported to use dynamic variables with AddDataSeries().

        From the help guide:
        "Tips
        2. You can add a custom BarsType 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 BarsPeriod values (such as Value2) of a custom BarsType in the BarsPeriod object initializer. For example: AddDataSeries(new BarsPeriod() { BarsPeriodType = (BarsPeriodType)14, Value = 10, Value2 = 20 });"


        Also from the help guide:
        "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."


        Any property that can be changed is dynamic. A hard coded value that does not change is not dynamic.

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          So, is there a feature request for this?

          Also, there are issues even when it is hard coded, I will open a different thread on that topic.

          Comment


            #6
            Also, you did not answer the question on if this can be done in general when not selecting a data series. There are other reasons to want to specify a bar type.

            Comment


              #7
              Hello aslane,

              Are you asking if there is a feature request for making a property of custom bar types?

              No, I am not aware of an existing feature request for this.

              The BarsPeriodType enum does not have the entries for custom bar types. This is why when adding a custom series with AddDataSeries it must be casted using the bar slot number.

              This means you would need to make a custom property and loop through the bar types to populate this custom property.

              The use case #3 in the 'Using a TypeConverter to Customize Property Grid Behavior' reference sample shows how to make a drop-down from a List<string>.


              The Bars Type Identifier demonstrates unsupported code to list the bar types.
              This is just a simple script which prints the BarsTypes and their BarsPeriodType ID as an integer. This is to aid in finding BarsPeriodType ID&#8217;s for the use with AddDataSeries syntax. For more apps from this user, check out the Trendline Detection tool!



              The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thanks I was hoping to avoid the type converter, but that does solve the issue.

                The feature request should be to "Allow dynamic bar series in AddDataSeries calls". Adding this would be huge win, as it allows doing higher timeframe work in a straight forward manner.

                Comment


                  #9
                  Hello aslane,

                  Yes, the request for the ability to use dynamic variables in AddDataSeries() is being tracked with ID# SFT-882.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by ninjatrader_chelseab View Post
                    the bars type identifier demonstrates unsupported code to list the bar types.
                    This is just a simple script which prints the BarsTypes and their BarsPeriodType ID as an integer. This is to aid in finding BarsPeriodType ID&#8217;s for the use with AddDataSeries syntax. For more apps from this user, check out the Trendline Detection tool!
                    wow yes yes yes please keep dropping this unsuported code it opens a world of possibility

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Tim-c, Today, 03:54 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post Tim-c
                    by Tim-c
                     
                    Started by FrancisMorro, Today, 03:24 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post FrancisMorro  
                    Started by Segwin, 05-07-2018, 02:15 PM
                    10 responses
                    1,772 views
                    0 likes
                    Last Post Leafcutter  
                    Started by Rapine Heihei, 04-23-2024, 07:51 PM
                    2 responses
                    31 views
                    0 likes
                    Last Post Max238
                    by Max238
                     
                    Started by Shansen, 08-30-2019, 10:18 PM
                    24 responses
                    945 views
                    0 likes
                    Last Post spwizard  
                    Working...
                    X