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

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



              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 cre8able, Today, 03:20 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post cre8able  
                    Started by Fran888, 02-16-2024, 10:48 AM
                    3 responses
                    45 views
                    0 likes
                    Last Post Sam2515
                    by Sam2515
                     
                    Started by martin70, 03-24-2023, 04:58 AM
                    15 responses
                    114 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by The_Sec, Today, 02:29 PM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    2 responses
                    31 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Working...
                    X