Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ninjascript to change chart background color

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

    ninjascript to change chart background color

    I am getting a compile error...

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

    with this statement

    ChartControl.ChartBackground = Brushes.Gold;

    (ChartBackground is a documented property of ChartControl)

    i have this using

    using NinjaTrader.Gui.Chart;


    how to fix?


    what I'm trying to do is to change the background color of all panels on the chart without changing the objects...

    in Ninja 7 I used this...

    ChartControl.BackColor = Color.Gold;



    #2
    Hello llanqui,

    Thank you for your post.

    You may use the Code Breaking Changes page of the help guide to verify changes between NinjaTrader 7 and NinjaTrader 8:


    BackColor from NinjaTrader 7 was changed to BackBrush in NinjaTrader 8:


    If you want to change the color of all panels on the chart, you may use BackBrushAll:


    Please let us know if we may be of further assistance.

    Comment


      #3
      thank you

      I am getting a compile error...

      if (BackBrushAll == Brushes.LimeGreen)
      BackBrushesAll = Brushes.Gold;
      Cannot implicitly convert type 'System.Windows.Media.SolidColorBrush' to 'NinjaTrader.NinjaScript.BrushSeries'
      ​​

      Comment


        #4
        Ok, should be BackBrushAll not BackBrushesAll

        :-)

        Comment


          #5
          well.....NO...what I really want is ChartControl.Background, to change the background color on the entire chart

          BackBrushesAll just changes the color of the background for the current bar on all panels


          but when I change ChartControl.Background all the bars and plots on all panels on the Chart disappear, I assume overlayed by the Background...

          basically I want to toggle the color of the chart background for different conditions, for example for printing (to change it to White)


          ????

          Comment


            #6
            Hello Ilanqui,

            Thank you for your reply.

            The correct use of the background property from ChartControl would be ChartControl.Properties.ChartBackground. That said, there is a warning that these are UI properties designed to be set by the user. Attempting to modify these values through a custom script is NOT guaranteed to take effect:


            If you wish to change the backbrush color for more than just the current bar, you could use BackBrushesAll with a barsAgo index to modify the collection of historical brushes for background colors on all chart panels:


            Please let us know if we may be of further assistance.

            Comment


              #7
              ok, well, Ninja 7 I didn't have to set all the back bars...

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              648 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              369 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              108 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              572 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              574 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X