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 bortz, 11-06-2023, 08:04 AM
        47 responses
        1,610 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        9 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        19 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        6 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        16 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X