Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Data above or below bar using volumetric bars data order flow chart of NT8.

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

    #16
    Thanks avrege. Compilation error is gone but i'm not seeing any plot in the chart

    Comment


      #17
      To get the value above the bar first assign it to double and then to draw it above bar use Draw.Text.Like this.

      double maxdelta1 = maxDelta[0];
      Draw.Text(this,"Test"+CurrentBar,(maxdelta1+""),0, (High[0] + 20), Brushes.Black);

      hope it will help

      Comment


        #18
        I'm trying the Addplot as shown in the example but i don't see the plot in the new panel / 2. I don't have any problem to draw the text either above or below the bar using draw.text.

        Comment


          #19
          Hello larrynq,

          Thanks for your reply.

          In order for a plot to appear in an indicator panel, the script must set IsOverlay = false in State.DataLoaded.

          If this does not resolve for you, please post a screenshot of your code.

          ​​​​​​​

          Comment


            #20
            Hello PaulH

            Please check below



            Thanks a lot for your help.

            Comment


              #21
              Hello larrynq,

              Thanks for your reply.

              It looks like you have created MaxDelta and MinDelta as private series.

              These are not needed because you are creating plots labeled MaxDelta and MinDelta. Please remove the private data series.

              In the #region Properties please make sure you have the following:

              [Browsable(false)]
              [XmlIgnore]
              public Series<double> MaxSeenDelta
              {
              get { return Values[0]; }
              }

              [Browsable(false)]
              [XmlIgnore]
              public Series<double> MinSeenDelta
              {
              get { return Values[1]; }
              }



              Comment


                #22
                Thanks a lot PaulH. It is working now. Thanks again

                Comment


                  #23
                  Hello,

                  Thanks for your post.

                  The links you posted regrettably are not helpful as they don't point to a specific file.

                  You posted what looks like your complete code file however there is so much irrelevant info that it makes your script difficult to follow. As a suggestion, either edit your post or write a new one and post the code starting from the line public class FOOTPRINTv1 : Indicator through #region NinjaScript generated code. Neither change nor remove.

                  The code above and below those lines generally is not needed for a review purpose.

                  You have a lot of lines of code commented out so again it is not clear what you are trying to do. If possible, please reduce the code to only what you are wanting to work with that is causing some issues. Please identify the error messages you are seeing.

                  Are you applying your code to a chart that already has volumetric bars? Or are you wanting to apply this to a chart of other bar types?
                  Last edited by NinjaTrader_PaulH; 07-20-2021, 05:46 AM. Reason: clarified

                  Comment


                    #24
                    Originally posted by NinjaTrader_PaulH View Post
                    Hello,

                    Thanks for your post.

                    The links you posted regrettably are not helpful as they don't point to a specific file.

                    You posted what looks like your complete code file however there is so much irrelevant info that it makes your script difficult to follow. As a suggestion, either edit your post or write a new one and post the code starting from the line public class FOOTPRINTv1 : Indicator through #region NinjaScript generated code. Neither change nor remove.

                    The code above and below those lines generally is not needed for a review purpose.

                    You have a lot of lines of code commented out so again it is not clear what you are trying to do. If possible, please reduce the code to only what you are wanting to work with that is causing some issues. Please identify the error messages you are seeing.

                    Are you applying your code to a chart that already has volumetric bars? Or are you wanting to apply this to a chart of other bar types?
                    Thanks a million for the reply.

                    I'm new to all of this (ninjascript - been trading for 10+ years) so I didn't know that you'd prefer only part of the code. I assumed it would be safer to include it in its entirety to make it easier by reducing the chances that I left something out.

                    I will come back later today and post this again after removing parts of the code.

                    All this is, is sample code to print squares from the help guide - modified to produce text above and below bars.

                    Then because this is meant to be run on a data series that is NOT volumetric, I've done my best to include the code as described in the language reference and also in this thread.

                    Comment


                      #25
                      Originally posted by NinjaTrader_PaulH View Post
                      post the code starting from the line public class FOOTPRINTv1 : Indicator through #region NinjaScript generated code. Neither change nor remove.
                      Before I do this I wanted to clarify: Did you want me to cut off the code before "#region NinjaScript generated code" or did you want me to include through the end of that secion?

                      Comment


                        #26
                        Hello,

                        Thanks for your reply.

                        The code below the line: #region NinjaScript generated code. Neither change nor remove. is not of interest.

                        Just to be clear, that code needs to be there in your ninjscript file, it just has no relevance to troubleshooting in this instance so no need to post it.

                        The goal would be to see what it is you are working with.

                        Thanks for asking.

                        Comment


                          #27
                          Editing in context from initial post in this thread:

                          "I was able to get it to successfully print text above and below bars. I was working towards getting it to print data from volumetric bars and also use data from volumetric bars for some other things.

                          I included what I saw in this thread, and I think that the program is ending because the variable we're creating barsType is null.

                          I'm brand new to ninjascript so I was hoping someone could point me in the right direction."



                          Code:

                          public class FOOTPRINTv1 : Indicator
                          {
                          private int rectWidth;

                          protected override void OnStateChange()
                          {
                          if(State == State.SetDefaults)
                          {
                          Name = "FOOTPRINTv1v1";
                          Calculate = Calculate.OnEachTick;
                          IsOverlay = true;
                          }
                          else if(State == State.Configure)
                          {
                          AddVolumetric("",BarsPeriodType.Minute,1,Volumetri cDeltaType.BidAsk,1);
                          }

                          }

                          protected override void OnBarUpdate()
                          {

                          NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = Bars.BarsSeries.BarsType as
                          NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

                          if (barsType == null)
                          return;

                          if (CrossAbove(Close, SMA(20), 1))
                          {
                          Draw.Text(this, "tag1" + CurrentBar, "text", 0,Low[1]-1);

                          }


                          else if (CrossBelow(Close, SMA(20), 1))
                          {


                          Draw.Text(this, "tag1" + CurrentBar, "text", 0,High[1]+1); //copied from above and modified to go above
                          }



                          }

                          #region Properties
                          #endregion
                          }
                          }

                          #region
                          Last edited by butt_toast; 07-20-2021, 12:00 PM.

                          Comment


                            #28
                            Hello,

                            Thanks for your reply.

                            I appreciate the effort to reduce down the code to what is of interest.

                            With reference to the example on this page of the help guide: https://ninjatrader.com/support/help...tric_bars2.htm

                            In the OnBarUpdate() you would need to first test if Bars are == null like this:

                            if (Bars == null)
                            return;


                            Next, you would need to add the volumetric bars type based on the added data series, like this:

                            NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as
                            NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;


                            BarsArray[1] is a pointer to the added volumetric series.

                            (Note: sometimes the forum editor puts inadvertent spaces in the middle of words so be careful if you copy/paste any out.)

                            The rest of the code seems like it should work. I did want to note that (using this as a reference but my comments apply to both statements) Draw.Text(this, "tag1" + CurrentBar, "text", 0,Low[1]-1); will draw the text based on the high or low of the previous bar [1] and will add or subtract a value of 1 point to it and the text would be placed above the current bar.

                            Typically you would use the current bars Low or High [0] but what you have will still place text on the chart.

                            Typically when adding (or subtracting) if you want to relate the offset in ticks you would use something like High[0] + 4 * TickSize, again your + or - 1 point also works.

                            Comment


                              #29
                              Originally posted by NinjaTrader_PaulH View Post
                              Hello,

                              Thanks for your reply.

                              I appreciate the effort to reduce down the code to what is of interest.

                              With reference to the example on this page of the help guide: https://ninjatrader.com/support/help...tric_bars2.htm

                              In the OnBarUpdate() you would need to first test if Bars are == null like this:

                              if (Bars == null)
                              return;


                              Next, you would need to add the volumetric bars type based on the added data series, like this:

                              NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as
                              NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;


                              BarsArray[1] is a pointer to the added volumetric series.

                              (Note: sometimes the forum editor puts inadvertent spaces in the middle of words so be careful if you copy/paste any out.)

                              The rest of the code seems like it should work. I did want to note that (using this as a reference but my comments apply to both statements) Draw.Text(this, "tag1" + CurrentBar, "text", 0,Low[1]-1); will draw the text based on the high or low of the previous bar [1] and will add or subtract a value of 1 point to it and the text would be placed above the current bar.

                              Typically you would use the current bars Low or High [0] but what you have will still place text on the chart.

                              Typically when adding (or subtracting) if you want to relate the offset in ticks you would use something like High[0] + 4 * TickSize, again your + or - 1 point also works.
                              Paul, thanks for the reply.

                              I'm circling back to this and am having issues converting the double to string (at least I think this is the issue).

                              Initially I tried just putting the barDelta variable in the Draw.Text() part but the editor was not pleased about that so I tried to convert the variable into a string. I found several different examples on this forum but none of them worked and felt it was time to reach out for some guidance.

                              How to I get Draw.Text() to allow me to pass it the variable barDelta? (with the intention of just grabbing any data point I can from the added volumetric data series, just trying to get anything to print at this point)

                              The code:

                              protected override void OnBarUpdate()
                              {
                              NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = Bars.BarsSeries.BarsType as
                              NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

                              double barDelta;


                              if (BarsInProgress == 1)//get values from footrpint
                              {
                              barDelta = barsType.Volumes[CurrentBar].BarDelta;
                              string barDeltaString = barDelta.ToString(barDelta);
                              }
                              if (barsType == null)
                              return;

                              if (CrossAbove(Close, SMA(20), 1))
                              {
                              Draw.Text(this, "tag1" + CurrentBar, barDeltaString, 0,Low[0] - (4*TickSize));
                              }
                              else if (CrossBelow(Close, SMA(20), 1))
                              {
                              Draw.Text(this, "tag1" + CurrentBar, barDeltaString, 0,High[0] - (4*TickSize));
                              }


                              }

                              Comment


                                #30
                                Hi, thanks for your reply.

                                You can convert the barDelta value to a string using this:

                                Code:
                                //in the using statements:
                                using System.Globalization;
                                
                                //OnBarUpdate:
                                
                                barsType.Volumes[CurrentBar].BarDelta.ToString(CultureInfo.InvariantCulture)
                                Please let me know if this does not resolve your inquiry.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                633 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                364 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                105 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                567 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                568 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X