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

Displaying the label for horizontal plot lines

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

    Displaying the label for horizontal plot lines

    I was comparing the Indicators that members have contributed (http://www.ninjatrader-support.com/v...1&sort=N&pp=15). In looking at the code, I've been unable to figure out how the labels are displayed differently.

    In the "Floor Pivots" indicator, the labels are on top of the horizontal lines on the right side.

    In the "SessionPivotsDaily V4" indicator, the labels are on the left side of the horizontal lines.

    Where in the code do I find this?

    #2
    I suggest contacting the author(s) for clarification.

    Comment


      #3
      I was wondering the same thing, so here is my take
      Session is using custom Plot
      int whiteBars = Math.Max(0, ChartControl.LastBarPainted - ChartControl.Bars[0].Count + 1);
      int x = (int) (ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2 - (ChartControl.BarsPainted - 1) * ChartControl.BarSpace + (count - whiteBars) * ChartControl.BarSpace);

      graphics.DrawString(plot.Name, ChartControl.Font, brush, lastX, lastY - ChartControl.Font.GetHeight() / 2, stringFormatFar);
      Floor is also using custom Plot
      int x = (int) (ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2 - (ChartControl.BarsPainted - 1) * ChartControl.BarSpace + count * ChartControl.BarSpace);

      graphics.DrawString("Floor " + plot.Name, ChartControl.Font, brush, firstX, lastY - ChartControl.Font.GetHeight(), stringFormat); //align label right

      Comment


        #4
        The use of custom plot is outside of the scope we can provide support for. Hint: Look for the x and y coordinate parameters on the DrawString. Those are the parameters that determine where the text will be print.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          DataSeries holding DateTime values?

          Just used graphics.DrawString to plot date labels next to Fibonacci lines.

          To do this I defined a DataSeries array (such as standard "Values" series used by the Plot method), as the date labels are supposed to change along with the values. As DataSeries does not hold DateTime values, I converted DateTime to Int (using a reference date), then converted this to double, stored it on the DataSeries array and retrieved it within the graphics.DrawString method by reconverting it back to Int, then DateTime and finally String to plot it.

          Is there any solution simpler than this, such as writing DateTime objects directly to a DataSeries?

          Comment


            #6
            Please see this article: http://www.ninjatrader-support.com/H...riesClass.html
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              DateTimeSeriesClass

              That is exactly what I was looking for. Did not know there was a DateTimeSeries class.

              Originally posted by NinjaTrader_Josh View Post

              Comment


                #8
                Starting plot labels from the left

                The graphics.DrawString method of the NT Pivot indicator plots labels from the right to the left. Is there any option to do it the other way round?

                Alternatively, is there any function that returns the plotted length of a string - not mystring.Length which would return the number of characters, but the length of the string as plotted to the chart?

                Comment


                  #9
                  Harry, to answer your first question: Not sure if there is an option to do it the other way around, but it is a standard .NET method. Here are the MSDN docs for Graphics.DrawString.

                  Second question: This might be possible (NinjaScript/NinjaTrader is C# so anything goes), but if it is possible it is not supported. Thank you for understanding.
                  AustinNinjaTrader Customer Service

                  Comment


                    #10
                    Thank you.

                    Thanks for the hint. Digging a bit in MSDN showed that I just had to replace "StringFormatFar" with "StringFormatNear".

                    Comment


                      #11
                      Harry, that's great to hear. A little digging can go a long way.
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        Documentation of ChartControl

                        Is there any documentation of ChartControl methods available? For quite a number of indicators it is necessary to overwrite the existing Plot Class.

                        Comment


                          #13
                          Harry, there is not any ChartControl documentation available. Overriding the Plot class is unsupported.
                          AustinNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by MSerag, Today, 11:52 PM
                          0 responses
                          1 view
                          0 likes
                          Last Post MSerag
                          by MSerag
                           
                          Started by DynamicTest, Today, 11:18 PM
                          0 responses
                          3 views
                          0 likes
                          Last Post DynamicTest  
                          Started by dcriador, Today, 01:43 AM
                          3 responses
                          20 views
                          0 likes
                          Last Post dcriador  
                          Started by smartromain, Today, 10:50 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post smartromain  
                          Started by popecapllc, 08-09-2023, 07:42 PM
                          10 responses
                          1,366 views
                          0 likes
                          Last Post BartMan
                          by BartMan
                           
                          Working...
                          X