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 can i add custom bar type to strategy?

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

    How can i add custom bar type to strategy?

    Hello,

    I have custom bar type and i want to use it secondary data series on my strategy. How can i do this?

    #2
    Hello,

    Please see the AddDataSeries documentation, there is an example that demonstrates using a custom BarsType. The "Tips:" section contains a few samples on adding custom types.




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

    Comment


      #3
      Hello Jesse,

      Sorry i did not pay attention. Thank you so much...

      Comment


        #4
        Is it possible to chose custom bar type as a parameter?

        I installed UniRenko and can choose it as a primary DataSeries, but don't see it in BarTypes list for property:
        Attached Files
        fx.practic
        NinjaTrader Ecosystem Vendor - fx.practic

        Comment


          #5
          Hello,

          Thank you for the post.

          I wanted to check, is this an item you have developed or something you have downloaded? This could be that the input is being limited to a certain set of types. If this is something you are creating, could you provide detail on the property used?

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

          Comment


            #6
            This is UniRenko bar type NT8b9 downloaded here:


            I installed UniRenko bar type NT8b9 in general way from zip file, I can see and use "UniRenko" bars type in Chart dialogue, as primary series in Strategy Analyser, but, I can't see it in drop down list of custom property of BarsPeriodType.
            Last edited by fx.practic; 08-16-2017, 07:58 AM.
            fx.practic
            NinjaTrader Ecosystem Vendor - fx.practic

            Comment


              #7
              Hello,

              Thank you for the reply.

              In this case, it would depend on how the property was created in the code for that script, the default BarsType selector would only display the internal types. If the developer has created their own property they could choose to list other bar types if they are available on the user's system and should be used with the strategy. This is not something we have a direct example of, but the developer could likely use logic like in the following post to determine if a specific type is included and what slot it occupies.




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

              Comment


                #8
                Thank You for providing so interesting code example.
                Here is output on my side:
                HTML Code:
                Day - 5
                Heiken Ashi - 9
                Kagi - 10
                Line Break - 13
                Minute - 4
                Month - 7
                Point and Figure - 12
                Range - 2
                Renko - 11
                Second - 3
                Tick - 0
                Volume - 1
                Week - 6
                Year - 8
                UniRenko - 501
                As we can see - UniRenko definitely present in system.
                But, I don't see the way to make handy BarsType selector.

                If to know exactly what bars are installed in particular system - custom enumeration can be used as type for BarsType selector.

                And how to make universal bar selector, independent of particular NT8 configuration?
                I feel hard lack of knowledges.
                Last edited by fx.practic; 08-17-2017, 12:41 PM.
                fx.practic
                NinjaTrader Ecosystem Vendor - fx.practic

                Comment


                  #9
                  Hello,

                  Any example on how to add the Renko or any exotic bar types as secondary data series?

                  Thanks

                  Comment


                    #10
                    Hello music_p13,

                    You can find this in the help guide on the following page:



                    Please see the Tips in the AddDataSeries page for Custom BarsTypes.





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

                    Comment


                      #11
                      Originally posted by NinjaTrader_Jesse View Post
                      Hello music_p13,

                      You can find this in the help guide on the following page:



                      Please see the Tips in the AddDataSeries page for Custom BarsTypes.





                      I look forward to being of further assistance.
                      Hello Jesse,

                      Thanks a lot, that did the trick for Renko bars.

                      However, when I am trying to add some other third party bars that are coded in DLL, they just don't show up in the loop...

                      Here is a sample code that works with Renko:
                      IEnumerable<Type> bars = Assembly.GetExecutingAssembly().GetTypes().Where(t => typeof(BarsType).IsAssignableFrom(t));
                      foreach (Type v in bars)
                      {
                      if (v.FullName != null)
                      {
                      BarsType bar = Activator.CreateInstance(Type.GetType(v.FullName)) as BarsType;
                      bar.SetState(State.SetDefaults);

                      int id = (int)bar.BarsPeriod.BarsPeriodType;
                      Print(string.Format("{0} - {1}", bar.Name, id, id));
                      if (bar.Name == "BetterRenko")
                      {
                      AddDataSeries((BarsPeriodType) id, 2);
                      return;

                      }
                      bar.SetState(State.Terminated);
                      }

                      }

                      Do you have any tricks on how to add 3rd party bars that are coded within a DLL (and are not in the bin\Custom\BarsTypes\ folder)?

                      Thanks

                      Comment


                        #12
                        Hello music_p13,

                        Please note, the bar finding syntax you have used should never be used directly with AddDataSeries specifically. That syntax should only be used in the original indicator to Print the integer ID number for the BarsType to the output window. Dynamically adding series like you have shown is not supported in NT8 and we document this in the AddDataSeries page to specifically avoid. Using dynamic variables with AddDataSeries is known to fail and should be avoided.

                        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.
                        The problem here is that you are using an old sample, please redownload the bars type identifier and re-import it. The newer code also searches external assemblies.


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

                        Comment


                          #13
                          Thanks!

                          The new code did the trick!

                          Thanks for very fast response!

                          Comment


                            #14
                            I am using the Unirenko bar that was created as a custom bar type, but I am trying to reference it in adding a volumetric data series so I can use the bar delta.. Can anyone help me here. Here is the code to add a volumetric data series for a builtin NT bar type as a starting point:

                            I installed the Unirenko type which is id = 501, and I want it set to Tick Trend =10, Open Offset = 4, Tick Reversal = 20

                            AddVolumetric("GC 04-20",BarsPeriodType.Minute,3,VolumetricDeltaType.Bi dAsk,1) ;

                            Jim-Boulder
                            NinjaTrader Ecosystem Vendor - Elephant Tracks

                            Comment


                              #15
                              Hi Jim-Boulder, thanks for your note.

                              I discussed accessing the secondary Volumetric series here in this post:


                              You need to create a VolumetricBarsType object (this can be done at the class level, not necessarily in OnBarUpdate)

                              Please let me know if I can assist any further.
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RookieTrader, Today, 09:37 AM
                              3 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by kulwinder73, Today, 10:31 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post kulwinder73  
                              Started by terofs, Yesterday, 04:18 PM
                              1 response
                              23 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by CommonWhale, Today, 09:55 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by Gerik, Today, 09:40 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post Gerik
                              by Gerik
                               
                              Working...
                              X