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

adding custom AddDataSeries minute bars vs unirenko charts

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

    adding custom AddDataSeries minute bars vs unirenko charts

    i know how to add a dataseries of a minute bar but how do you add the information of a unirenko bar

    AddDataSeries(Data.BarsPeriodType.Minute, 30);

    here is the info in the unirenko bartype


    Description = @"NT8 UniRenko";
    Name = "UniRenko";
    BarsPeriod = new BarsPeriod { BarsPeriodType = (BarsPeriodType)20, BarsPeriodTypeName = "UniRenko(20)", Value = 1 };
    BuiltFrom = BarsPeriodType.Tick;
    DaysToLoad = 3;
    DefaultChartStyle = Gui.Chart.ChartStyleType.CandleStick;
    IsIntraday = true;


    public override void ApplyDefaultValue(BarsPeriod period)
    {
    period.BarsPeriodTypeName = "UniRenko";
    period.BaseBarsPeriodValue = 10; //### Open Offset Value
    period.Value =4; //### Trend Value
    period.Value2 = 20; //### Reversal Value
    }

    // I tried this but I can't figure it out.


    AddDataSeries(NinjaTrader.NinjaScript.BarsTypes.Un iRenko,004010020);

    #2
    I placed this code in and wanted to see if the dataseries was printing properly


    if (State == State.SetDefaults)
    {

    //AddDataSeries(Data.BarsPeriodType.Custom1,00400200 4);
    //AddDataSeries("sss",BarsPeriodType.Tick,


    BarsPeriod = new BarsPeriod {
    BarsPeriodType = (BarsPeriodType)12345,
    BarsPeriodTypeName = "UniRenko",
    };


    }
    else if (State == State.Configure)
    {


    AddDataSeries(new BarsPeriod() {
    BarsPeriodType = (BarsPeriodType)12345,
    Value = 20,
    Value2 = 4,
    BaseBarsPeriodValue = 10
    });

    }


    I tested on a 1 minute chart
    but my data is incorrect


    if(BarsInProgress ==1)
    {
    Print(Close[0] + "Close");
    Print(High[0] + "High");
    Print(Low[0] + "Low");
    Print(Open[0] + "Open");
    }

    this is my unirenko chart 10,4,20
    o:6748.0
    H: 6748.75
    L6744.75
    C:6748.00

    on my 1 minute chart it states
    O6749.75
    C:6748,75
    H:6754.5
    L:6744.75

    I am trying to get these to match

    Comment


      #3
      I got it solved.


      This is my answer.

      {


      AddDataSeries(new BarsPeriod() {
      BarsPeriodType =(BarsPeriodType) 12345,
      BarsPeriodTypeName = "UniRenko",
      BaseBarsPeriodValue = 10,
      Value = 20,
      Value2 = 4
      });


      and testing

      protected override void OnBarUpdate()
      {


      if(CurrentBars[0] <1 || CurrentBars[1] <1)
      return;


      if(BarsInProgress ==0)
      {
      Print("5 minute");
      Print(Open[0] + "Open");
      Print(Close[0] + "Close");
      Print(High[0] + "High");
      Print(Low[0] + "Low");

      }


      if(BarsInProgress ==1)
      {
      Print("^^^^^^^^^^");
      Print(Open[0] + "Open");
      Print(Close[0] + "Close");
      Print(High[0] + "High");
      Print(Low[0] + "Low");

      }
      }

      Comment


        #4
        Hello ballboy11,

        Thanks for your inquiry and sharing your results.

        For the thread's reference, when adding a data series for a custom BarType, the AddDataSeries overload using a BarsPeriod must be used. This BarsPeriod must be made with the BarType's index casted to BarsPeriodType. This can be referenced in the custom BarType's source code, or the can be asked from the BarType's developer.

        Other BarsPeriod properties will also have to be supplied to configure the BarType. The BarsPeriod documentation page can be referenced for how NinjaTrader uses these properties. Their usage likely will vary for the custom BarType, so referencing that source code or consulting the developer is advised.

        BarsPeriod - https://ninjatrader.com/support/help...barsperiod.htm

        AddDataSeries - https://ninjatrader.com/support/help...dataseries.htm

        Please let us know if there is anything else we can do to assist.
        JimNinjaTrader Customer Service

        Comment


          #5
          Have error on add data series

          I have 2 indicators that I need to add custom data series
          if (State == State.Configure)
          {
          AddDataSeries(new BarsPeriod() {
          BarsPeriodType =(BarsPeriodType) 12345,
          BarsPeriodTypeName = "UniRenko",
          BaseBarsPeriodValue = nOpenOffset,
          Value = nRangeReversalSize,
          Value2 = nTrend
          });

          }

          This works on my computer but when I installed it to a friends computer to backtest I get an error.

          In the trace log this is what I get.
          Error on calling 'OnStateChange' method: 'AddDataSeries' method: There exists no implementation for this 'BarsPeriod' object.


          I checked if they have a UniRenko Bar on their computer and they do.

          Indicator was compressed to dll for testing.

          Comment


            #6
            Hello ballboy11,

            I may suggest including the custom BarsType with your export. It could be that the BarsType on your friend's PC has a different index for the BarsPeriodType. I have attached 2 examples showing how custom BarsTypes can be added to an indicator.

            Note: 3rd party custom BarsTypes are not supported by NinjaTrader. Please consult the original BarsType developer for any related questions with custom BarsTypes.

            Please let us know if we can be of further assistance.
            Attached Files
            JimNinjaTrader Customer Service

            Comment


              #7
              this information is in the unirenko I downloaded from you.



              Description = @"Universal renko bar type. Ported by Sim22, 2015. [email protected]";
              Name = "UniRenko";
              BarsPeriod = new BarsPeriod { BarsPeriodType = (BarsPeriodType) 501, BarsPeriodTypeName = "UniRenkoBarsType(501)", Value = 1 };
              BuiltFrom = BarsPeriodType.Tick;
              DaysToLoad = 3;
              IsIntraday


              so when I install this unirenko it has the custom value of 501 so when I add this to my indicator

              if (State == State.Configure)
              {


              AddDataSeries(new BarsPeriod() {
              BarsPeriodType = (BarsPeriodType)501,// do I use 501, because i used 12345 in my code earlier
              Value = 20,
              Value2 = 4,
              BaseBarsPeriodValue = 10
              });



              }

              O

              Comment


                #8
                Hello ballboy11,

                The UniRenko BarsType included with this package has its BarsPeriodType index defined on line 52.

                BarsPeriod = new BarsPeriod { BarsPeriodType = (BarsPeriodType) 501, BarsPeriodTypeName = "UniRenkoBarsType(501)", Value = 1 };
                You may reference the custom BarsType's source code for the BarsPeriodType index on your end, or you may consult the BarsType developer that has created the BarsType.

                Please let me know if you have any questions.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Thank you. I understand where to get the code, but my question is if I am creating an indicator such as the 501 reference in your statement below, when I produce all indicators do I reference the 501?

                  Comment


                    #10
                    Hello ballboy11,

                    Yes, the BarsPeriodType index should not change unless the BarsType changes, so you will have to use consistent references in each of your indicators.

                    I.E BarsType has 501: Indicator A and Indicator B must both reference (BarsPeriodType)501 if they are to add that BarsType.

                    Please let me know if this does not resolve your inquiry.
                    JimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by llanqui, Today, 08:32 AM
                    1 response
                    8 views
                    0 likes
                    Last Post llanqui
                    by llanqui
                     
                    Started by lollers, Yesterday, 03:26 AM
                    1 response
                    53 views
                    0 likes
                    Last Post lollers
                    by lollers
                     
                    Started by Salahinho99, 05-05-2024, 04:13 AM
                    7 responses
                    62 views
                    0 likes
                    Last Post Salahinho99  
                    Started by knighty6508, 05-10-2024, 01:20 AM
                    4 responses
                    30 views
                    0 likes
                    Last Post knighty6508  
                    Started by OllieFeraher, 05-09-2024, 11:14 AM
                    6 responses
                    19 views
                    0 likes
                    Last Post OllieFeraher  
                    Working...
                    X