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

Indicator for Data Box only

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

    Indicator for Data Box only

    Hello,

    I coded an indicator that is really only useful in the Data Box. But, I needed plot info for looking at information for a given bar. Is there a way to just have the indicator show in the Data Box without being on the chart?

    Click image for larger version

Name:	image.png
Views:	363
Size:	71.1 KB
ID:	1239498

    Bar Info is the indicator and it show the ranges of the bar, Low-to-High, Open-to-Close, what percentage of the candle is body, and whether the bar is an Up (1), Down (-1), or Doji(0). As you can see, the plots are meaningless, but knowing the characteristics of the bar is helpful in debugging indicators or strategies.

    So, the Data Box entry is useful but the plots are not. And, I have to minimize the panel whenever I add it or make changes to the indicators applied to the chart.

    Anyway to avoid adding a panel and still have the info in the Data Panel?

    Thanks,
    Matt

    #2
    Hello StealthM93,

    Thank you for your post.

    If you would like to add the indicator without adding a panel by default, you can set IsOverlay to true in State.SetDefaults:


    Additionally, although you need the plots in order to see the values in the databox, you can set the plot colors to transparent and then also enable ShowTransparentPlotsInDataBox to true in State.SetDefaults:


    With these changes, adding the indicator should result in no visual changes to your chart; it will be adding transparent plots to the same panel as the input series and the plot values will still show in the data box.

    Please let me know if I may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Thank you, NinjaTrader_Emily,

      That works! But, something rather odd has happened. The indicator has an option to display the ranges in Points or Ticks. When in Ticks, the range numbers would be whole numbers (see original post). Now, they are shown with 2 decimals places.

      Click image for larger version  Name:	image.png Views:	0 Size:	7.1 KB ID:	1239510​​
      This is for the same bar in my original post.

      So, I'm getting the same info but having the whole numbers for the Ticks setting would be nice (same for the UDD value). Is there something I can do to revert this?

      [EDIT, added this question]
      What is the difference between DrawOnPricePanel and IsOverlay?


      Thanks!
      Matt
      Attached Files
      Last edited by StealthM93; 03-10-2023, 06:28 PM.

      Comment


        #4
        Hello Matt,

        Thank you for your reply.

        In relation to the values shown with two decimal places, I am curious - which version of NinjaTrader are you using? This may be found at Control Center > Help > About. Are you able to reproduce this behavior with any other indicator that would normally display values in a whole number, such as VolumeUpDown? I tried making a copy of that script and the only change I made was setting ShowTransparentPlotsInDataBox to true in State.SetDefaults. When I set the plots to transparent, the plot values were still in whole numbers in the data box.

        DrawOnPricePanel is related to drawing objects; when set to true, which is the default value, draw objects are painted on the price panel. If it is set to false, the draw objects will be painted on the indicator panel. For more information:I look forward to your response.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Hello NinjaTrader_Emily,

          I am using 8.0.27.1. One thing to note, since I use the same field for either Ticks or Points, it is a double field. The UDD result is an integer. Of course, all the Values[] are doubles. The script is below, very simple. I have not tested with another indicator.

          Thanks for taking a quick look.

          Matt

          ----------
          Code:
          public class jtBarInfo : Indicator
          {
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = @"Displays bar information for the Data Box";
          Name = "jt Bar Info";
          Calculate = Calculate.OnBarClose;
          BarsRequiredToPlot = 2;
          IsOverlay = true;
          DisplayInDataBox = true;
          DrawOnPricePanel = false;
          PaintPriceMarkers = false;
          ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
          ShowTransparentPlotsInDataBox = true;
          //Disable this property if your indicator requires custom values that cumulate with each new market data event.
          //See Help Guide for additional information.
          IsSuspendedWhileInactive = true;
          AddPlot(Brushes.Transparent, "High-Low");
          AddPlot(Brushes.Transparent, "Open-Close");
          AddPlot(Brushes.Transparent, "Percent Body");
          AddPlot(Brushes.Transparent, "Up Down Doji");
          }
          else if (State == State.Configure)
          {
          }
          }
          
          protected override void OnBarUpdate()
          {
          if (CurrentBar < BarsRequiredToPlot) return;
          
          double barRange = High[0] - Low[0];
          double barBody = Close[0] - Open[0];
          
          Values[0][0] = SelectPointOrTicks == PointsOrTicks.Points ? barRange : barRange / TickSize;
          Values[1][0] = SelectPointOrTicks == PointsOrTicks.Points ? barBody : barBody / TickSize;
          Values[2][0] = (barRange > 0.000000001) ? (Math.Abs(barBody) / barRange) * 100.0 : 0.0;
          Values[3][0] = barBody > 0.0 ? 1 : (barBody < 0.0 ? -1 : 0);
          }
          
          [HASHTAG="t3322"]region[/HASHTAG] Properties
          
          [NinjaScriptProperty]
          [Display(Name = "Display Value", Description = "Select to show Points or Ticks", GroupName = "Settings", Order = 1)]
          public PointsOrTicks SelectPointOrTicks { get; set; }
          
          [Browsable(false)]
          [XmlIgnore]
          public Series<double> BarRangeHiLo
          {
          get { return Values[0]; }
          }
          
          [Browsable(false)]
          [XmlIgnore]
          public Series<double> BarRangeOpenClose
          {
          get { return Values[1]; }
          }
          
          [Browsable(false)]
          [XmlIgnore]
          public Series<double> BarPctBody
          {
          get { return Values[2]; }
          }
          
          [Browsable(false)]
          [XmlIgnore]
          public Series<double> UpDownDoji {
          get { return Values[3]; }
          }
          #endregion
          
          }​

          Comment


            #6
            Originally posted by StealthM93 View Post
            That works! But, something rather odd has happened. The indicator has an option to display the ranges in Points or Ticks. When in Ticks, the range numbers would be whole numbers (see original post). Now, they are shown with 2 decimals places.
            You can FormatPriceMarker to address this.
            Last edited by QuantKey_Bruce; 03-15-2023, 08:55 AM.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #7
              Hello StealthM93,

              Thank you for your patience.

              Is the points or ticks input set up as an enum so it shows up on the UI as a dropdown menu? I am not seeing the enum in the snippet you shared. You could try adding print statements that print the value of each variable used throughout your script to see if the formatting is changing at some point due to one of the values used. For more information about using prints to debug your script:


              Otherwise, along the lines of FormatPrice that Bruce has mentioned, you could try using FormatPriceMarker() if you'd like to specify the number of decimal places shown:


              For more information about formatting numbers:


              Please let me know if I may be of further assistance.
              Emily C.NinjaTrader Customer Service

              Comment


                #8
                Hello NinjaTrader_Emily / QuantKey_Bruce

                Yes, the PointsOrTicks is an enum in a supporting utility static class that I wrote.

                Thank you for the reference to FormatPriceMarker method. However, that does not apply here as I'm not dealing with price. If I'm missing something and it does apply, how do I apply it to the different Valuesx] entries?

                All the Values[x] are doubles. It just happened that when those values were whole numbers, they displayed as such. That is, the Values[0] and Values[1] displayed as whole when the SelectPointsOrTicks is Ticks. Same with UDD, which is just -1, 0, 1. None of that code changed from before, so no need for print statements.

                Any other ideas are welcome! (But, this isn't a major issue as the correct data is being displayed.)

                Thanks,
                Matt

                Comment


                  #9
                  If you override FormatPriceMarker you can do something like number.ToString("#") and it will just display the whole number, both in the floating marker (if enabled) and in the data box.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #10
                    Thank you QuantKey_Bruce.

                    I understand that. The challenge is that Values[0] or Values[1] maybe decimal or whole number (Points - decimal, Ticks - whole). Values[2] will always be decimal (% of the bar that is body) and Values[3] is always whole (-1 down, 0 doji, 1 up). I'm now added two more values that always doubles (%'s).

                    In looking at examples, there is a single override on a price parameter. So, how do I apply a Formatter to each?

                    Thanks,
                    Matt

                    Comment


                      #11
                      FormatPriceMarker, unfortunately, would not be able to distinguish which plot it is formatting because it only accepts a double as a parameter.

                      One possibility you could explore is to just output it like number.ToString() - that would be just "3" in the case of 3 or it would be 1.234567 in the case of that number.

                      Another possibility is you could do something like .ToString("0.####") which would be a whole number for a whole number, or up to 4 decimal places but not more.
                      Bruce DeVault
                      QuantKey Trading Vendor Services
                      NinjaTrader Ecosystem Vendor - QuantKey

                      Comment


                        #12
                        Thanks Bruce. This is for the display in the Data Box, which takes its values from the Plots. This is not for an Output window or for text on chart.

                        Comment


                          #13
                          Hello StealthM93,

                          Thank you for your patience.

                          I would like to take a step back and try to further evaluate the underlying concern. Initially, before the plots were transparent, you were seeing the values in the data box as either whole numbers when set to ticks or with two decimal places when set to points, correct? Yet after changing the plots to be transparent, you now see the numbers with two decimal places whether they are set to ticks or doubles?

                          Please provide a reduced version of the script (or scripts) that still demonstrates these two behaviors so I may test on my end. To export a script, please go to Control Center > Tools > Export > NinjaScript AddOn. Once exported, you may upload the file as an attachment to your forum post. I would like to test the colored plots that show the values as expected in the data box as well as the transparent plots that do not.

                          I appreciate your time and look forward to your reply.
                          Emily C.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello NinjaTrader_Emily,

                            I'm finally getting back to this. Thank you for your offer to investigate further.

                            Originally posted by NinjaTrader_Emily View Post
                            Hello StealthM93,
                            Before the plots were transparent, you were seeing the values in the data box as either whole numbers when set to ticks or with two decimal places when set to points, correct? Yet after changing the plots to be transparent, you now see the numbers with two decimal places whether they are set to ticks or doubles?
                            Yes, that is correct, just as you described.

                            Unfortunately, exporting with NT8 install is not working (already reported), so I modified the script to be self-contained so that it doesn't rely on my "library" class. That is, I have a local enum for the Point or Ticks option. I have confirmed that the same behavior exists with this small update.

                            The indicator file is attached. Thank you for taking a look!

                            Kind regards,
                            Matt
                            Attached Files

                            Comment


                              #15
                              Hello Matt,

                              Thank you for that information.

                              Using the script you provided, I was able to get the values to show in the data box with the decimal places. Please advise what needs to be modified or provided a separate script that reproduces the original behavior where the plots were not transparent and the values for ticks were whole numbers in the data box.

                              I look forward to assisting you further.
                              Emily C.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by thanajo, 05-04-2021, 02:11 AM
                              3 responses
                              469 views
                              0 likes
                              Last Post tradingnasdaqprueba  
                              Started by Christopher_R, Today, 12:29 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post Christopher_R  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              166 responses
                              2,237 views
                              0 likes
                              Last Post sidlercom80  
                              Started by thread, Yesterday, 11:58 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post thread
                              by thread
                               
                              Started by jclose, Yesterday, 09:37 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post jclose
                              by jclose
                               
                              Working...
                              X