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 CortexZenUSA, Today, 12:53 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by CortexZenUSA, Today, 12:46 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by usazencortex, Today, 12:43 AM
    0 responses
    5 views
    0 likes
    Last Post usazencortex  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    168 responses
    2,265 views
    0 likes
    Last Post sidlercom80  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    11 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X