Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaTrader.Gui.Chart.ChartControl

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

    NinjaTrader.Gui.Chart.ChartControl

    ‘NinjaTrader.Gui.Chart.ChartControl’ does not contain a definition for ‘Font' and no extension method ‘Font’ accepting a first argument of type ‘NinjaTrader.Gui.Chart.ChartControl ’ could be found(are you missing or using directive or an assembly reference?)

    So Instead of Font which definition is needed to use in NinjaTrader 8 ?

    Thanks

    #2
    Hello tpotrades,

    Thanks for opening the thread.

    The property is now a SimpleFont object called LabelFont. You can access it from ChartControl.Properties.LabelFont.

    However this cannot be changed in code as it is intended to be changed from the user interface. From the help guide:
    Warning: These are UI properties which are designed to be set by a user. Attempting to modify these values through a custom script is NOT guaranteed to take effect.
    https://ninjatrader.com/support/help...properties.htm

    SimpleFonts can be referenced here: https://ninjatrader.com/support/help...font_class.htm

    Please let me know if I can be of further help.

    Comment


      #3
      So can I just replace Font for SimpleFont??

      Sorry for my bad coding

      Comment


        #4
        Hello tpotrades,

        Yes, methods that used to use Font's in NinjaTrader 7 now use SimpleFonts in NinjaTrader 8.

        You can look at Draw.Text() and DrawText() as an example:
        DrawText() - https://ninjatrader.com/support/help...7/drawtext.htm
        Draw.Text() - https://ninjatrader.com/support/help.../draw_text.htm

        Please let me know if you have any questions.

        Comment


          #5
          Still giving me the same error.

          This is the line with the error:
          largerFont = new SimpleFont( ChartControl.LabelFont.Name, msTextFontSize) { Bold = true };

          I changed Font to Labelfont but now giving exactly the same error.

          In the same indicator I have another error on this line:
          if (IsFirstTickOfBar && Close[1] > StdErrorSmoothV2(opacityMiddle,opacityOuter,period ,smoothing,widthMiddle,widthOuter).Upper[1] && Close[2] < StdErrorSmoothV2(opacityMiddle,opacityOuter,period ,smoothing,widthMiddle,widthOuter).Upper[2])

          Giving me this error:
          No overload for method ´StdErrorSmoothV2´takes 6 arguments

          Thanks

          Comment


            #6
            Hello tpotrades,

            Thank you for the reply.

            SimpleFont objects are used for various Drawing methods in NinjaTrader 8 and can also be used when defining UI elements for Add-ons. In your case, we will be utilizing a SimpleFont object that we declared as a LabelFont stored within Chart.Control.Properties. This will be stored within the OnBarUpdate method:

            I have reworked a basic example found in our Help Guide to include the SimpleFont object as a LabelFont.

            Please see the following block of code as an example for how to accomplish this:

            protected override void OnBarUpdate()
            {
            NinjaTrader.Gui.Tools.SimpleFont myFont = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 12) { Size = 20, Bold = true };
            Draw.Text(this, "myTag", false, "Hi There!", 0, Low[0], 5, Brushes.Blue, myFont, TextAlignment.Center, Brushes.Black, null, 1);
            ChartControl.Properties.LabelFont = myFont;
            }

            In regards to your second inquiry regarding the error for "StdErrorSmoothV2", you may be utilizing the incorrect number of parameters in your code. I have created an example of this error on my end by declaring 4 parameters using the SMA indicator when it should only use 2.

            Please see the attached screenshots and let me know if you have any additional questions.
            Attached Files

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            576 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X