• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rendering Rectangle / Logo to appear on lower left side of chart?

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

    Rendering Rectangle / Logo to appear on lower left side of chart?

    Hello,

    I'm trying to load the logo and some basic information on the lower left side of the corner of the chart. This code works well with all my rendering, however it shows on the left top corner.


    RenderTarget.DrawBitmap(myBitmap, new SharpDX.RectangleF(30,30, 300, 63), 9.0f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear);

    I changed the x,y coordinates but not sure if that is correct way. -30 / -30 doesn't work for x,y value.

    How can i change this so that the box appears on the lower left corner?




    #2
    Hello priceisking,

    Thank you for your note.

    The Sample custom render indicator included with NinjaTrader is an example that has text that is rendered at the bottom right.
    This is a good sample to use to see how to render at the bottom left. See the lowerTextPoint declaration.

    The panel will go from 0, to the ChartPanel.H (height). You will want to be some pixels above the bottom. (ChartPanel.H minus the size of your text, or minus the distance in pixels from the bottom)
    https://ninjatrader.com/support/help...chartpanel.htm
    Last edited by NinjaTrader_ChelseaB; 05-20-2019, 02:11 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Great. This is awesome. I am not an advance level programmer and SharpDX is quite new to me . .. I was wondering where does the term "Upper Left Corner" and "Lower Right Corner" come from in the code? I'm trying to see if i can replace just those words to see if I understand it better. But not able to do it.

      I think once i figure that out, i should be able to figure out the rendering of text boxes . Please let me know.

      Comment


        #4
        Hello priceisking,

        These strings come from a resource dictionary so that we can make the text show in different languages.

        NinjaTrader.Custom.Resource.SampleCustomPlotLowerR ightCorner is a string from a resource dictionary that has this text and is supplied as the string text parameter to the SharpDX.DirectWrite.TextLayout() on line 268.

        You would just use a normal string, it doesn't need to be from a resource dictionary.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you . This worked.

          Comment


            #6
            When i try to create a textbox on the chart, what are the x,y coordinates for lower left corner? I am successfuly able to put a text box on the upper left corner and lower right corner, but i am unable to find the coordinates for lower left corner and upper right corner. Can you help?


            DrawTextBox(RenderTarget, ChartPanel, label, Font, labelTextBrush, ChartPanel.X , ChartPanel.Y , areaBrush, borderBrush);

            Comment


              #7
              Hello priceisking,

              The bottom of the chart panel is ChartPanel.H.
              The left of the panel is 0.
              The top of the panel is 0.
              The right of the panel is ChartPanel.W

              https://ninjatrader.com/support/help...chartpanel.htm

              DrawTextBox() is not a NinjaTrader or SharpDX method that I know of.

              Are you referring to RenderTarget.DrawText()?

              Are you referring to your own custom method?
              Last edited by NinjaTrader_ChelseaB; 05-23-2019, 09:40 AM.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Ahh ok. .. So this is what i'm doing and trying to get the rectangle to show up on the lower left corner and adjust if the chart is scaled up or down so that it doesn't go off the charts.
                It's actually a function call. was getting confused with the various different ways to accomplish what i'm trying to do. All i'm trying to do is create a simple rectangular box on the lower left corner that shows the actual PnL (realized, unrealized, account value).


                public void DrawTextBox(SharpDX.Direct2D1.RenderTarget renderTarget, ChartPanel chartPanel, string text, SimpleFont font, SharpDX.Direct2D1.Brush brush, double pointX, double pointY, SharpDX.Direct2D1.Brush areaBrush, SharpDX.Direct2D1.Brush borderBrush)
                {
                SharpDX.DirectWrite.TextFormat textFormat = font.ToDirectWriteTextFormat();
                SharpDX.DirectWrite.TextLayout textLayout =
                new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Gl obals.DirectWriteFactory,
                text, textFormat, 1000,
                textFormat.FontSize);
                SharpDX.Vector2 TextPlotPoint = new System.Windows.Point(pointX, pointY).ToVector2();

                float newW = textLayout.Metrics.Width;
                float newH = textLayout.Metrics.Height;

                SharpDX.RectangleF PLBoundRect = new SharpDX.RectangleF((float)pointX - 2, (float)pointY - 2, newW + 4, newH + 4);

                renderTarget.FillRectangle(PLBoundRect, areaBrush);
                renderTarget.DrawRectangle(PLBoundRect, borderBrush);

                renderTarget.DrawTextLayout(TextPlotPoint, textLayout, brush, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
                textLayout.Dispose();
                textFormat.Dispose();
                }

                Comment


                  #9
                  Hello priceisking,

                  The left of the panel x position would be 0.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello SAILIKITY,

                    The left x position would be 0. The bottom Y position would be ChartPanel.H.

                    Negative values would not be in the viewable area.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by chazyang, Today, 02:01 AM
                    1 response
                    3 views
                    0 likes
                    Last Post chazyang  
                    Started by tonynt, Today, 01:20 AM
                    0 responses
                    12 views
                    0 likes
                    Last Post tonynt
                    by tonynt
                     
                    Started by sdauteuil, Yesterday, 11:02 PM
                    1 response
                    3 views
                    0 likes
                    Last Post sdauteuil  
                    Started by Jschmelz, Yesterday, 04:45 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Marco  
                    Started by sisenberg, Yesterday, 08:06 PM
                    1 response
                    11 views
                    0 likes
                    Last Post sisenberg  
                    Working...
                    X