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:
      https://ninjatrader.com/support/help...barsperiod.htm

      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:	24
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():
            https://ninjatrader.com/support/help...ndatapoint.htm

            You can add and update bars with AddBar() and UpdateBar():
            https://ninjatrader.com/support/help...nt8/addbar.htm
            https://ninjatrader.com/support/help.../updatebar.htm

            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 satoyama, Yesterday, 01:28 AM
            2 responses
            25 views
            0 likes
            Last Post satoyama  
            Started by borxhils, Yesterday, 11:27 PM
            0 responses
            1 view
            0 likes
            Last Post borxhils  
            Started by bmaltz, 12-01-2022, 07:15 PM
            2 responses
            15 views
            0 likes
            Last Post bmaltz
            by bmaltz
             
            Started by iceman600, 12-01-2022, 01:51 PM
            4 responses
            25 views
            0 likes
            Last Post iceman600  
            Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
            55 responses
            13,426 views
            3 likes
            Last Post grimes12  
            Working...
            X