Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question regarding creating your own font object in NT7 script

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

    Question regarding creating your own font object in NT7 script

    How does one create their own font object in NT7 script? For NT8, for example, I know I can use the following:

    NinjaTrader.Gui.Tools.SimpleFont myFont = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 12) { Size = 50, Bold = true };

    Draw.Text(this, "myTag", false, "Hi There!", 0, Low[0], 5, Brushes.Blue, myFont, TextAlignment.Center, Brushes.Black, null, 1);

    What is the NT7 equivalent of the code for creating "myFont"? I tried using the same SimpleFont syntax but it produced an error when I tried to compile it. Please let me know. Thanks.

    #2
    Hello mbesha,

    Thank you for writing in.

    You will want to create a Font object.

    Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.


    As an example:
    Code:
    private Font myFont = new Font("Times New Roman", 24);
    
    protected override void OnBarUpdate()
    {
    	DrawTextFixed("Text", "Hello world!", TextPosition.BottomRight, Color.Blue, myFont, Color.Transparent, Color.Transparent, 0);
    }
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      It worked! Thanks.

      Comment


        #4
        How do you add bold text with this?

        Comment


          #5
          Hello brucelevy,

          You will use the constructor that accepts FontStyle.

          Initializes a new Font that uses the specified existing Font and FontStyle.


          Code:
          Font(string familyName, float emSize, FontStyle style)
          Zachary G.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sjsj2732, Yesterday, 04:31 AM
          0 responses
          27 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          284 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          280 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          132 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          90 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X