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 judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            59 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            21 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            10 views
            0 likes
            Last Post cre8able  
            Working...
            X