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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            606 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            353 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            561 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X