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

The problem with programming UniRenkoBars

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

    The problem with programming UniRenkoBars

    Hello, please tell me how to call in the code UniRenkoBars. The problem is that there are 3 settings and I do not understand how to program them
    Add(PeriodType.Custom5, ???);

    #2
    Add(PeriodType.Custom5, 004008002); //TickTrend=4 , TickReversal=8, OpenOffset=2

    Comment


      #3
      bltdavid, thank you very much for your help. Could you explain how you understand that it is necessary to program these bars in this way?

      Comment


        #4
        Hello Kovalev,

        Officially custom bar types are not supported for NinjaTrader 7 so this is not documented in the help guide.

        This kind of undocumented workarounds can be found through the forum.

        Below is a link to one such thread.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by Kovalev View Post
          bltdavid, thank you very much for your help. Could you explain how you understand that it is necessary to program these bars in this way?
          Because if you read the source code for the UniRenko bar type, which is located in bin/Custom/Type/UniRenkoBarsType.cs, that's how you do it.

          There is very specific code in that file that will decode that large single combined parameter into its 3 constituent small parameters.

          Go find it.

          Comment


            #6
            Originally posted by bltdavid View Post

            Because if you read the source code for the UniRenko bar type, which is located in bin/Custom/Type/UniRenkoBarsType.cs, that's how you do it.

            There is very specific code in that file that will decode that large single combined parameter into its 3 constituent small parameters.

            Go find it.
            Yes, I found it. With it, I figured out that it is called as Custom 5. And just saw that there are three parameters, but why 004008002, not 4, 8, 2

            Comment


              #7
              Originally posted by Kovalev View Post

              Yes, I found it. With it, I figured out that it is called as Custom 5. And just saw that there are three parameters, but why 004008002, not 4, 8, 2
              Because the Add() method has no overload accepting those 3 integer parameters.

              So, whereas the BarType programmer can create a new bar type and force the Data Series dialog to accept 3 parameters, there were no work-aounds to make Add() accept 3 parameters, since that kind of change would have to come from NinjaTrader programmers internally.

              Thus, the designer of UniRenko had to get very creative. Many people wanted to use his UniRenko bars programmatically, but there was no way to specify the required 3 parameters.

              What to do?
              What to do?

              Well, he got to thinking.

              What if he created a specially encoded single parameter that contained all 3 numbers organized in a very specific way, so that he could decode that huge-ish number back into 3 small numbers, and do that decoding on the very first bar of the chart?

              Ok, how does it work, you ask?

              Say you wanted a 2-6-3 UniRenko chart.

              The BarInterval parameter is calculated like this,

              Code:
              int BarInterval = 2*1000000 + 6*1000 + 3;
              which you pass to Add(), via normal,

              Code:
              Add(PeriodType.Custom5, BarInterval);
              And that, combined with the code you found to decode it, is why it works.

              So, why he had to do it this way was because there was no official way to do it.

              He had to use the raw language ability of C# to invent something to workaround the lack of foresight & functionality provided by NinjaTrader's limited Add() method. Because he only had one integer parameter to work with.

              He had to get very clever.

              Necessity was the mother of invention.

              Make sense?

              PS:
              The whole ordeal and subsequent solution is chronicled fairly well at BigMike's -- which is now at http://www.futures.io.
              Last edited by bltdavid; 12-24-2018, 07:14 AM.

              Comment


                #8
                bltdavid, thank you very much, a more complete answer is impossible to imagine!

                Comment


                  #9
                  While this is a valid way to do it there are at least two other ways to do this where digit parsing is not needed. you can use just the integer values. Sadly, because this is how I make my living, no free code examples.
                  RJay
                  NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                  Comment


                    #10
                    Originally posted by RJay View Post
                    While this is a valid way to do it there are at least two other ways to do this where digit parsing is not needed. you can use just the integer values. Sadly, because this is how I make my living, no free code examples.
                    Yes, there are other ways. They are not as secret as you imply.

                    A code sample is straight forward, RJay, nothing earth-shattering ...

                    For example,

                    Code:
                    protected override void Initialize()
                    {
                        Add(PeriodType.Custom5, 2);
                        if (BarsPeriods.Length > 0)
                        {
                            BarsPeriods[BarsPeriods.Length-1].Value2 = 6;
                            BarsPeriods[BarsPeriods.Length-1].BasePeriodValue = 3;
                        }
                    }
                    should set up the same 2-6-3 UniRenko chart.

                    Comment


                      #11
                      Do you work for free? I have bills that need to be paid. I never said anything about it being a "Secret". Your code would not be my first choice but if it works terrific, thank you for sharing.
                      RJay
                      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                      Comment


                        #12
                        Thanks, RJay, I respect your work

                        However, if you felt unable to really contribute to the discussion, then why did you reply at all?

                        I mean, your first comment was a bit odd of sorts, as it added absolutely nothing to the core of
                        public knowledge ... I mean, zero, bud, ... nada, zilch ... that's not like you. So, why reply at all?

                        I mean, your saying "I have other ways, but sorry, I won't show you" is a bit pointless, don't you think?

                        Did I miss something?

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by traderqz, Today, 09:44 AM
                        2 responses
                        4 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by stafe, 04-15-2024, 08:34 PM
                        8 responses
                        40 views
                        0 likes
                        Last Post stafe
                        by stafe
                         
                        Started by rocketman7, Today, 09:41 AM
                        2 responses
                        6 views
                        0 likes
                        Last Post rocketman7  
                        Started by rocketman7, Today, 02:12 AM
                        7 responses
                        31 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by guillembm, Yesterday, 11:25 AM
                        3 responses
                        16 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X