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 Kowking, Today, 02:58 AM
            0 responses
            1 view
            0 likes
            Last Post Kowking
            by Kowking
             
            Started by LavniaCardos, Today, 02:32 AM
            0 responses
            1 view
            0 likes
            Last Post LavniaCardos  
            Started by pstrusi, 11-13-2022, 05:23 PM
            23 responses
            398 views
            0 likes
            Last Post pstrusi
            by pstrusi
             
            Started by Murphy67, Today, 01:10 AM
            2 responses
            12 views
            0 likes
            Last Post DiverG20  
            Started by DiverG20, Today, 02:01 AM
            0 responses
            4 views
            0 likes
            Last Post DiverG20  
            Working...
            X