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 create a new bar type?

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

    How to create a new bar type?

    Hello,

    I'm wanting to create a custom Renko bar that is offset by 50%.

    Using NinjaScript Editor I opened the Renko bar and used Save As to save it to RenkoCustom (yes an overrode the name in OnStateChanged), and compiled it.

    The new bartype RenkoCustom does not appear as a choice when I edit DataSeries.

    Am I missing a step?

    Many Thanks, Caesar.

    #2
    Hello Caesar,

    Double check that you updated the Name attribute in the OnStateChange() method (this may be near the bottom of the code file). It'll look something like this:

    Code:
    if (State == State.SetDefaults)
    {
    Name = Custom.Resource.NinjaScriptBarsTypeRenko;
    - to -

    Code:
    if (State == State.SetDefaults)
    {
    Name = "RenkoCustom"; // Or whatever name you want

    Recompile and open a new Data Series. Hopefully, your new bar type will be there.

    Hope that helps!
    Matt

    Comment


      #3
      Hello Caesar,

      Thank you for your note.

      I understand you overrode the name in OnStateChange, which is also what Matt mentioned. Do you receive an error message in the Log tab of the Control Center? If so, what does the message say?

      A common item when making a new BarsType is to get an error regarding the BarsPeriodType. If this is the case, I suggest reviewing the following link:


      There is a tip on that page regarding custom BarsTypes as follows:
      Tip: When creating custom BarsTypes, it is recommended to pick high, unique enumeration value to avoid conflict from other BarsTypes that may be used by a single installation.

      BarsPeriod = new BarsPeriod { BarsPeriodType = (BarsPeriodType)123456, BarsPeriodTypeName = "MyCustomBars", Value = 1 };

      It could be that you need to adjust the BarsPeriod so there is no overlap with the existing Renko BarsPeriodType.

      Please let us know if we may be of further assistance.
      Emily C.NinjaTrader Customer Service

      Comment


        #4
        Hello Emily,

        I Saved As the Renko bar as RenkoCustom, changed the name and recompiled.

        RenkoCustom appears in NinjaScript Editor but not in the chart Data Series.

        Many Thanks, Caesar.

        Comment


          #5
          Hello Emily,

          You were right about the BarsPeriod type!

          Now, I need the modify this to show an offset Renko bar.

          What do I need to change to make it like this?
          Click image for larger version

Name:	Screenshot 2022-10-06 131630.jpg
Views:	114
Size:	18.6 KB
ID:	1218593

          Many Thanks, Caesar.

          Comment


            #6
            Hello Caesar,

            Thanks for the reply. Glad to hear that worked!

            The calculations for the data points of the bars are handled in OnDataPoint():


            You can add and update bars with AddBar() and UpdateBar():



            Since you made a copy of the Renko bar type, I recommend reviewing the logic inside of OnDataPoint() and making the adjustments necessary to get your desired offset.
            NOTE: When testing changes to your BarsType, you must compile your changes, then shut down NinjaTrader and delete the cache in the Documents\NinjaTrader 8\db\cache folder to rebuild the cache. Another option is to run tests on the Playback connection, as this connection does not use the cache.

            Please feel free to reach out with any additional questions or concerns.
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by PaulMohn, Today, 12:36 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by yertle, Yesterday, 08:38 AM
            8 responses
            36 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Started by rdtdale, Today, 01:02 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by alifarahani, Today, 09:40 AM
            3 responses
            17 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by RookieTrader, Today, 09:37 AM
            4 responses
            20 views
            0 likes
            Last Post RookieTrader  
            Working...
            X