Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw string in a rectangle

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

    Draw string in a rectangle

    In NT7 I could draw string in a specified rectangle like that :

    public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)

    I cannot find the same method with Draw.Text. How can I replicate the same behavior in NinjaTrader 8


    thanks

    #2
    Originally posted by blar58 View Post
    In NT7 I could draw string in a specified rectangle like that :

    public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)

    I cannot find the same method with Draw.Text. How can I replicate the same behavior in NinjaTrader 8


    thanks
    That must be a method that you created yourself or in a library that you downloaded. NT7 has no such method that I have ever seen or can find.

    Of course, in a custom Plot, you do have a graphics context that you can reference, but that is not quite the signature either. You must draw as a method from the graphics object.
    Last edited by koganam; 10-13-2015, 10:32 AM.

    Comment


      #3
      Hello blar58,

      Thanks for your post.

      Can you provide an export of an indicator that you are calling DrawString in?

      To export your script do the following:
      1. Click File -> Utilities -> Export NinjaScript
      2. Enter a unique name for the file in the value for 'File name:'
      3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
      4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message


      By default your exported file will be in the following location:
      • (My) Documents/NinjaTrader 7/bin/Custom/ExportNinjaScript/<export_file_name.zip>


      Below is a link to the help guide on Exporting NinjaScripts.
      http://www.ninjatrader.com/support/h...nt7/export.htm
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Maybe that's my mistake.

        Here is the method that I used with NT7 :

        void Graphics.DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)

        I am looking tor the equivalent in NinjaTrader 8
        Last edited by blar58; 10-13-2015, 10:45 AM.

        Comment


          #5
          Hello blar58,

          The graphics library is part of WPF rendering provided to the Plot override and is not provided by the OnRender method in NT8.

          NinjaTrader 8 no longer uses WPF rendering and is now using SharpDX rendering.

          Instead you may be looking for:
          RenderTarget.DrawText(string text, TextFormat textFormat, RectangleF layoutRect, Brush defaultForegroundBrush)
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            This is exactly what I was looking for.

            Thank you _ChelseaB

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by mmckinnm, Today, 01:34 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Conceptzx, 10-11-2022, 06:38 AM
            3 responses
            60 views
            0 likes
            Last Post NinjaTrader_SeanH  
            Started by f.saeidi, Today, 01:32 PM
            1 response
            2 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by traderqz, Today, 12:06 AM
            9 responses
            16 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by kevinenergy, 02-17-2023, 12:42 PM
            117 responses
            2,766 views
            1 like
            Last Post jculp
            by jculp
             
            Working...
            X