Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change the background color within script.

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

    Change the background color within script.

    I want to change the background color of my chart from within my NT8 script. Can you help me?

    #2
    When using NinjaScript, you can change the background color
    on the main chart panel for the current bar using BackBrush.

    To change the background color of all panels, use BackBrushAll.

    For previous bars, use BackBrushes or BackBrushesAll.

    Comment


      #3
      This does not tell me how to change all bars.

      Comment


        #4
        Originally posted by galsermil View Post
        This does not tell me how to change all bars.
        Well, you could just change the background color of each bar,
        one at a time, inside OnBarUpdate -- and just keep using the
        same color each time -- I mean, just use OnBarUpdate to set
        the background to the same color, one bar at time.

        Remember, BackBrush and BackBrushAll are continually
        updated to refer to the background color of the most recently
        closed bar.

        Otherwise if you want to change the background of all bars
        at once, you have to use your programming skills.

        How so? Use the plural variant and set the background color
        in a loop, for each bar, like this,

        Code:
        for (int indx = 0; indx < CurrentBar; ++indx)
            BackBrushes[indx] = Brushes.LightSkyBlue;
        Make sense?

        Comment


          #5
          Oh, wait ...

          Maybe you mean this.

          Scroll down to 'ChartBackground'.

          Comment


            #6
            This is my second attempt at solving this mystery. When I first advised of this this loop solution, my script merely skipped over it but I was not surprised as my CurrentBar was 15641. That is a lot of bars to process.

            Comment


              #7
              Originally posted by galsermil View Post
              This is my second attempt at solving this mystery. When I first advised of this this loop solution, my script merely skipped over it but I was not surprised as my CurrentBar was 15641. That is a lot of bars to process.
              Then a solution could be to process just those bars that are visible on screen, but then, if you scroll back, previous bars would not have that color.

              Tip#2: if you choose OnBarUpdate solution, make sure, you are not using it within backtest/optimization, as it's fully redundant to render any colors and it would eat up lots of space.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              53 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              130 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              70 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              44 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              49 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X