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 alifarahani, Today, 09:40 AM
        6 responses
        27 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        13 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Waxavi, Today, 02:00 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        17 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X