Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing the color of bars ...

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

    Changing the color of bars ...

    I am trying to figure out how to change the color of the bars at runtime based upon a calculation in my study. I cannot get it to work.

    I have got this far but I could use a little help please...

    Code:
      xclose[0] = (Open[0]+High[0]+Low[0]+Close[0])/4.0;
    			xopen[0] = (xopen[1] + xclose[1])/2.0;
    			
    			if ( xclose[0] > xopen[0] ) {
    				ChartControl.ChartStyle.UpColor = Color.Green;
    				ChartControl.ChartStyle.DownColor = Color.Green;
    			}
    			else {
    				ChartControl.ChartStyle.UpColor = Color.Red;
    				ChartControl.ChartStyle.DownColor = Color.Red;
    			}
    The above code changes the colors one time and never changes them back again. As you can see I am trying to color the candles using the heiken ashi fomula, so I want the upColor and DownColor to be equal depending on the values of xclose and xopen....

    Thanks for any help

    #2
    Use BarColor

    I suggest to use BarColor, for example

    Code:
    if (Close[0] > Open[0])
    BarColor = Color.Lime;
    else if (Close[0] < Open[0])
    BarColor = Color.Red;
    should do the trick.

    Comment


      #3
      Thank You very much Harry.

      The only reason I am posting on top of your post is to add one more bit ...

      I find that after coloring the bar with BarColor I need to reset the CandleOutlineColor to black because, by default, the CandleOutlineColor is set to the BarColor.

      So here is what works

      BarColor = Color.Lime;
      CandleOutlineColor = Color.Black.

      Comment


        #4
        Bob, glad to hear you got it figured out. Harry, thank you for your assistance. Please let us know if you have any other questions.
        AustinNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        90 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        48 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        31 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        34 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        69 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X