Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to code change of color of a panel background

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

    How to code change of color of a panel background

    Hello,
    What's the most straightforward way to programmatically (in an indicator's code) change the background color of a panel? I mean all the background of the panel at once, not just the part corresponding to one given bar. Thanks.

    #2
    Hello supernatural,

    You can work with BackColorSeries for this.


    You would have to program a loop that iterates through all bars of the series.

    if (Close[0] > Open[0])
    for (int x = 0; x < CurrentBar, x++)
    {
    BackColorSeries[x] = Color.Black;
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hello RyanM,

      Thank you. Can the original (unmodified) color be accessed somewhere or do I have to store it in a variable if I want to get it back after I modified the values of BackColorSeries?

      Comment


        #4
        You would have to store it somewhere. Once it's been changed by code, any calls to the BackColor property will return the modified color.

        Here's a quick snippet that tests for conditions in real time and changes background colors. When the conditions aren't true, it colors red.

        Code:
         
        if (!Historical && Close[0] > Open[0])
        for (int x = 0; x < CurrentBar; x++)
        {
        BackColorSeries[x] = Color.Green;
        }
        
        else
        for (int x = 0; x < CurrentBar; x++)
        {
        BackColorSeries[x] = Color.Red;
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks a lot. I understand the values in BackColorSeries can't be recalled once they're modified but is there a property that contains the background color for the panel as it is defined by the user in the graphical interface?

          Comment


            #6
            Unfortunately this is not supported for programmatic access supernatural.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            82 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            43 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            64 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            68 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            56 views
            0 likes
            Last Post CarlTrading  
            Working...
            X