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

Drawing Labels in Y Scale

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

    Drawing Labels in Y Scale

    I am doing some custom rendering and I need labels in the Y scale at certain values. Things I have tried:

    1. Draw my own labels in OnRender: This works but labels appear to go under the Y scale. I think they are just off the chart canvas
    2. Add a Plot and set the value but change the line color to transparent: Hides the line just fine but also hides the label

    Is there any known approach to putting labels in the Y scale? Custom Rendering or otherwise?

    #2
    Hello swcooke,

    There are no supported methods for rendering in the price margin on a chart.

    A plot can be added to an indicator, and on each new bar of the indicator the BarBrush can be set to transparent. The plot label would still be colored in this approach.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am still not understanding. Is there a more specific example you could give? Here is what I tried in an effort to show the label of Plot1 without the line:

      Code:
              protected override void OnStateChange()
              {
                  if (State == State.SetDefaults)
                  {
                      Description                                    = @"Enter the description for your new custom Indicator here.";
                      Name                                        = "CandleTest";
                      Calculate                                    = Calculate.OnPriceChange;
                      IsOverlay                                    = false;
                      DisplayInDataBox                            = true;
                      DrawOnPricePanel                            = true;
                      DrawHorizontalGridLines                        = true;
                      DrawVerticalGridLines                        = true;
                      PaintPriceMarkers                            = true;
                      ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                      IsSuspendedWhileInactive                    = true;
                      DrawLabel     = true;
                      AddPlot(new Stroke(Brushes.Black), PlotStyle.Line, "Plot1");
                  }
                  else if (State == State.Configure)
                  {
                  }
              }
      
              protected override void OnBarUpdate()
              {
                  if(DrawLabel){
                      Plot1[0] = Close[0];
                      Plots[0].Brush = Brushes.Transparent;
                  }
      
              }

      Comment


        #4
        Hello swcooke,

        I am suggesting you set the BarBrush for each bar not the plot brush.

        Below is a link to the help guide which includes an example.


        Code:
        protected override void OnBarUpdate()
        {
        Value[0] = Close[0];
        BarBrush = Brushes.Transparent;
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          My request is for a way to draw a label in a pane that I am custom rendering in. Not in the main pane. I have added the plot because it gets me the label. However, I don't want to see the line the plot draws. I just want to see the label. Setting BarBrush = Brushes.Transparent just changes the color of the brush used in the main pane. It seems to have no effect on my Plot.

          Comment


            #6
            Hello swcooke,

            You have previously mentioned:

            " I need labels in the Y scale at certain values"

            When you mention the Y scale are you talking about the price margin to the right of the chart?

            Also, you are correct, it would not be the BarBrush... it would be the PlotBrushes. That was my mistake. Sorry about the confusion on that.



            PlotBrushes[0][0] = Brushes.Transparent;
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              PlotBrushes[0][0] = Brushes.Transparent; makes the label transparent as well. I am trying to keep the label. When I mention the Y scale, I am referring to the right scale of my indicator pane.

              Comment


                #8
                Hello swcooke,

                I overlooked that the last bar cannot be set. This means at least one bars plot value would need to be visible on the chart.

                So if (CurrentBar > 0) PlotBrushes[0][1] = Brushes.Transparent; would likely be as close as this could get.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Chelsea,

                  There has to be a better way to get a simple price marker in the scale. Can you share this post with the team and see if there are any better ideas for getting this done?

                  Comment


                    #10
                    Hello swcooke,

                    One suggestion that came from the team is to prevent all rendering from the indicator completely.

                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Why do I feel like we are going round and round here? That example does nothing more than what my original example does. Which is further highlight the fact that this is not possible. And the post you referenced is from 2012 and is littered with upvotes for a way to do this. Has the development team rejected this idea or is it still in the works since 2012? What am I missing here? How can I view the development teams response to why this was not implemented?

                      Comment


                        #12
                        Hello swcooke,

                        It is not possible to show a plot marker without a plot using any supported methods. The post linked shows a feature request ID where this is being taken in consideration and shows a workaround of preventing the plot from being rendered but still showing the plot marker in the price margin.

                        It is up to the NinjaTrader Development to decide if or when any request will be implemented.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Your work around to prevent the plot from being rendered while still showing the label, does not work. Feel free to test for yourself and if you are able to get it working, send me the exported indicator so I can import a working version?

                          Comment


                            #14
                            Hello swcooke,

                            Attached is a screenshot of how the example script linked in post #10 looks on my end without any modifications to the code.

                            May I have a screenshot of how this looks on your end (on a chart with no other indicators applied)?

                            If you are experiencing different behavior, please send an email to platformsupport [at] ninjatrader [dot] com so that I may test the example script on your end. In the email please included a link to this forum thread.
                            Attached Files
                            Last edited by NinjaTrader_ChelseaB; 05-23-2019, 11:41 AM.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello bandass,

                              Have you attempted what is shown in the example linked in post #10?

                              I am doing some custom rendering and I need labels in the Y scale at certain values. Things I have tried: 1. Draw my own labels in OnRender: This works but labels
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              41 views
                              0 likes
                              Last Post alifarahani  
                              Working...
                              X