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 GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,281 views
        0 likes
        Last Post Leafcutter  
        Started by WHICKED, Today, 12:45 PM
        2 responses
        19 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by Tim-c, Today, 02:10 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        5 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        53 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Working...
        X