Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawText() Font Problem

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

    DrawText() Font Problem

    In the region Variables section I have added:
    private System.Drawing.Font textFont, Arrow;

    In the Initialize() section I have added:
    Font textFont = new Font("Lucida Console", 8);
    Font Arrow = new Font("Wingdings 3", 8);

    Then in the OnBarUpdate() section I added the following:

    DrawText("Tag1", false, "u", 0, High[0], 0, Color.Black, Arrow, StringAlignment.Far, Color.Transparent, Color.Transparent,0);

    The text prints, but it uses the default font, instead of the font I specified.

    I can force it to use the desired font by specifying it directly in the DrawText statement as below, but I shouldn't have to do that. Where am I going wrong?

    DrawText("Tag1", false, "u", 0, High[0], 0, Color.Black, new Font("Wingdings 3", 8), StringAlignment.Far, Color.Transparent, Color.Transparent,0);

    #2
    Hello JackW,

    Thank you for writing in.

    You should assign the font within region variables section rather than in Initalize, for example,
    Code:
    private System.Drawing.Font Arrow = new Font("Wingdings 3", 8);
    Which will allow you to pass that font into your drawtext method within onbar update.

    A reference example which demonstrates this, Changing fonts for draw objects, can be found at the following link,


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sjsj2732, 03-23-2026, 04:31 AM
    0 responses
    77 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    313 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    314 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    149 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    114 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X