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

Accessing Chart Background Color

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

    Accessing Chart Background Color

    Hi,

    I would like to ask if anyone knows how to access the background color of a chart programatically? I am specifically referring to the color you set in Chart properties under Window and then Background color. I change the background color as part of my indicator set ups and I would like to revert to the original color via the program when I am done. Thank you.

    #2
    Hello Zeos6,

    Thank you for your post.

    We do not have a supported method to access the chart color properties, however another member may have some experience they can share with you.

    You can always use the BackColor property to access the color value that an indicator is using.

    if (BackColor == Color.Green)
    // do something

    More information on BackColor can be found below:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Thank you Mathew. I am aware of what you have indicated.
      I understand that you do not have a supported method to access the Chart Properties but can you at least tell me where they are stored; i.e. System.Control.... or System.Windows.Forms...
      Thank you.

      Comment


        #4
        Originally posted by Zeos6 View Post
        Thank you Mathew. I am aware of what you have indicated.
        I understand that you do not have a supported method to access the Chart Properties but can you at least tell me where they are stored; i.e. System.Control.... or System.Windows.Forms...
        Thank you.
        ChartControl.BackColor

        Comment


          #5
          Hi Koganam,

          Thank you very much. It is very easy to access the background color of the chart programatically now that I have this info. Many thanks.

          Comment


            #6
            And how is it possible to set chart background color with an indicator?

            Many thanks.

            Thomas

            Comment


              #7
              Hello,

              You can use the OnStartUp event to declare the background color:

              Code:
              		protected override void OnStartUp()
              		{
              		 	ChartControl.BackColor = Color.Aquamarine;
              		}
              MatthewNinjaTrader Product Management

              Comment


                #8
                Hi Matthew,
                Thanks for your answer, do you work weekends ;-) .
                I'd like to change background color according to certain conditions met calculated in the indicator. Like "all in long" color background green.

                Thanks

                Thomas

                Comment


                  #9
                  I normally do not work weekends, I'm filling in for a colleague who is out enjoying the summer, but we normally have techs scheduled working the weekend.

                  In the case you wish to change the background under a specific condition, you may use the supported 'BackColor" property:

                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    That is nice to know, that somebody is available at weekends. :-)

                    I know BackColorAll, but it colors only the background of bars an not the whole chart background.

                    Imagine, you have 10 charts on yours screen and just need to glance at it to know which is trending.

                    Thanks

                    Thomas

                    Comment


                      #11
                      Thomas,

                      In that case, you'd have to use the ChartControl property in OnBarUpdate:

                      Code:
                             protected override void OnBarUpdate()
                              {
                               
                      			if(Close[0] > SMA(5)[0])
                      				ChartControl.BackColor = Color.Green;
                      			
                      			else if(Close[0]< SMA(5)[0])
                      				ChartControl.BackColor = Color.Red;
                              }
                      MatthewNinjaTrader Product Management

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by SherwoodJP, 06-04-2024, 06:55 AM
                      4 responses
                      44 views
                      0 likes
                      Last Post SherwoodJP  
                      Started by dibDab, 11-09-2022, 09:04 AM
                      13 responses
                      120 views
                      0 likes
                      Last Post MisterTee  
                      Started by LordNoah, Today, 06:15 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post LordNoah  
                      Started by oneybuchi2, Today, 03:48 PM
                      2 responses
                      21 views
                      0 likes
                      Last Post oneybuchi2  
                      Started by samish18, Today, 04:59 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post samish18  
                      Working...
                      X