Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 helpwanted, Today, 03:06 AM
    1 response
    7 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    7 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X