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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            673 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            379 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            111 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            577 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            582 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X