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 BackToTheFutures, 08-17-2021, 03:15 PM
    8 responses
    730 views
    0 likes
    Last Post joehanus  
    Started by elirion, Yesterday, 09:32 PM
    0 responses
    8 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by cre8able, Yesterday, 09:15 PM
    1 response
    8 views
    0 likes
    Last Post bltdavid  
    Started by cummish, Yesterday, 08:43 PM
    0 responses
    16 views
    0 likes
    Last Post cummish
    by cummish
     
    Started by Option Whisperer, Yesterday, 07:58 PM
    4 responses
    21 views
    0 likes
    Last Post Option Whisperer  
    Working...
    X