Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing the background color of the entire chart

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

    Changing the background color of the entire chart

    In development of my NT8 script for Forex, I want to change the background color of the entire chart depending on whether there are no active trades, 1 active trade, or 2 active trades. Yesterday I was using <Brush> and the background was changing when processing historical data but it did not change with realtime data. I changed to <BrushAll> and it changes the background for 1 bar only. I would like to be sure that I am using the correct command and then I can look for other problems..

    #2
    Hello galsermil,

    Thanks for your post.

    BackBrush could be used to color the background of a chart for the current bar.

    BackBrushAll could be used to color the background of a char for the current bar for all chart panels.

    BackBrushes could be used to color the background of a chart for historical bars. BackBrushes is a collection of historical brushes used for the background colors for the chart panel. Accessing this property via an index value [int barsAgo] returns a Brush object representing the color of the background color on the referenced bar.

    BackBrushesAll could be used to color the background of a chart for historical bars for all chart panels. This is a collection of historical brushes used for the background colors for all chart panels.

    Something you could consider is looping through all the bars on the chart and calling BackBrushes to change the color of the background for all the bars on the chart.

    See the attached example script demonstrating this.

    Also, see the help guide documentation below for more information and sample code.

    BackBrush: https://ninjatrader.com/support/help.../backbrush.htm
    BackBrushAll: https://ninjatrader.com/support/help...ckbrushall.htm
    BackBrushes: https://ninjatrader.com/support/help...ackbrushes.htm
    BackBrushesAll: https://ninjatrader.com/support/help...brushesall.htm

    Let us know if we may assist further.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Brandon, do you also have to do this when returning to the default color as the Users Guide says that if you use BackBrushesAll = null it will return you to the default in 'Properties'.?

      Comment


        #4
        Brandon, I am not sure about the definition of BarIndex but if it is from the beginning, my chart has 15m bars. Is it practical to go that far back?

        Comment


          #5
          Hello galsermil,

          Thanks for your note.

          BackBrushes[0] and BackBrushesAll[0] will not use the default color when setting BackBrushes[0] = null or BackBrushesAll[0] = null. This would assign a null value to BackBrushes[0] or BackBrushesAll[0].

          This would only apply when calling BackBrush or BackBrushAll as seen in the sample code of the BackBrush and BackBrushAll help guide pages.

          BarIndex is an int variable that represents the loop variable. This variable could easily be replaced with something called 'i', for example.

          It would be up to you to determine how far back you would like to loop through the bars on the chart depending on your overall goal.

          Let us know if we may assist further.




          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Brandon, based on you example, I am tying to create an indicator with a user input for number of bars back and the color. For some reason the script will not allow me to use <BackBrushes[BarIndex] =Brushes,BackColor> Its the use of BackColor as a variable. Can you tell me what I need to do to use a variable for the Brushes Color

            Comment


              #7
              Hello galsermil,

              Thanks for your note.

              You could use the Strategy Builder to create a user-defined Brush variable named something like 'myBrushVariable' in the Inputs and Variables screen and click the 'View code' button to see the generated code.

              After defining the user-defined Brush variable in your script, you could assign that variable to BackBrushes[barIndex].

              BackBrushes[barIndex] = myBrushVariable;

              Let me know if I may further assist.
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              62 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              134 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              75 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              50 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X