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 helpwanted, Today, 03:06 AM
        1 response
        7 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        7 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        5 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X