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

Changing default font

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

    Changing default font

    Hello,

    I know that I can control font size by passing font variable in Draw.Text signature. Is there a way to set default font size for all Draw.Text without specifying it for each occurrence?

    Sorry, meant to post it in NT8 section.

    Thanks,
    redduke

    #2
    Hello RedDuke,

    Thanks for your post (we'll move it to NT8).

    Yes, you can create a simplefont variable in your script and then use that variable as needed.

    Example:

    private SimpleFont textFont;

    (in State.Dataloaded) textFont = new SimpleFont("Impact", 10);

    (In OnBarUpdate) Draw.Text(this, "textA"+CurrentBar, true, "Example text to print", 0, High[0] + 4 * TickSize, 0, Brushes.Gold, textFont, TextAlignment.Center, Brushes.Black, Brushes.Red, 50);
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      That is exactly the jist of my question, can I just globally set default font and omit specifying textFont below? It is not a requires signature variable to pass to Draw.Text


      Draw.Text(this, "textA"+CurrentBar, true, "Example text to print", 0, High[0] + 4 * TickSize, 0, Brushes.Gold, textFont, TextAlignment.Center, Brushes.Black, Brushes.Red, 50);

      Thanks,
      redduke

      Comment


        #4
        Hello RedDuke,

        Thanks for your reply.

        My apologies for misreading your original post.

        "can I just globally set default font and omit specifying textFont below? It is not a requires signature variable to pass to Draw.Text"
        Background: The Draw.Text method will use the default text as found/defined in the Text drawing tool. If you create a text tool template with the name of Default then it will override the original settings and be applied to all instances of the Draw.Text when there is no font override used in the method.

        The Draw.Text method has 5 different overloads as listed in the help guide: https://ninjatrader.com/support/help...?draw_text.htm The first two can only use the Default text template (original or if user created). The third has a provision for using a non default template (allowing you to use as many different font color/size/style templates as you wish).
        The last two allow you to override the default font.

        In test here it looks like you can pass null on the last two for the font and it will use the default font.
        Draw.Text(this, "mytest"+CurrentBar, true, "Text", 0, High[0]+5 * TickSize, 0, Brushes.Lime, null, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul,

          text tool template Default worked great.

          Thanks a lot

          Comment


            #6
            Hello,

            I have noticed an weird issue with fonts. I ran 10 years of back-test on 2 hour bars, and it typically runs 25 seconds. When I set default text template, the worsens by almost 4 times to about 1.5 min. If I remove default, and pass font in Draw.Text signature, the speed worsens by 2 times, to about 50 seconds. Once fonts are removed, all back to normal. Any idea why it would happen? I do print a lot on the chart. Almost every bar gets some kind of label, sometimes more than 1.

            Thanks,
            redduke

            Comment


              #7
              Hello RedDuke,

              Thanks for your post.

              I roughly calculate that 10 years of 2 hour bars is going to be about 30,000 bars. If you are drawing 30,000 draw objects (plus) I would expect there to be some delay in processing. Certainly using draw template means for each use that the template font/data must be retrieved and the font generated. Using a font in the signature means that it also has to generate the local font data. An option you can consider that when back testing to not draw text (or other objects) through the use of a bool that you set in the UI when backtesting.

              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_PaulH View Post
                Hello RedDuke,

                Thanks for your post.

                I roughly calculate that 10 years of 2 hour bars is going to be about 30,000 bars. If you are drawing 30,000 draw objects (plus) I would expect there to be some delay in processing. Certainly using draw template means for each use that the template font/data must be retrieved and the font generated. Using a font in the signature means that it also has to generate the local font data. An option you can consider that when back testing to not draw text (or other objects) through the use of a bool that you set in the UI when backtesting.
                Makes sense. Thanks a lot for clarifying it. Still in awe about NT8 performance vs NT7 Amazing software!!!!!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by maybeimnotrader, Yesterday, 05:46 PM
                1 response
                18 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Perr0Grande, Yesterday, 08:16 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by f.saeidi, Yesterday, 08:12 AM
                3 responses
                25 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by algospoke, Yesterday, 06:40 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by quantismo, Yesterday, 05:13 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X