• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarColor of current realtime forming bar only

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

    BarColor of current realtime forming bar only

    Please can someone help me. I am trying to change the bar color and outline color of the current forming bar only.

    I use the following code:
    protected override void OnBarUpdate()
    {
    if (CurrentBar == Count -1) //Current Bar Only
    {
    CandleOutlineColor = Color.LightGray;
    BarColor = Color.LightGray;
    }
    }


    However when the current bar closes, it keeps the color that I am setting rather than returning to the default data series bar and outline colors as defined in the data series. I need to recalculate the indicator to repaint the bars that have closed since the last time the indicator was inserted or recalculated.

    How do I make it so that only the current bar has a different color and when it closes it gets the default data series color?

    Many thanks.

    #2
    OK I managed to fix it using the series variables instead and resetting the previous bar to the default.

    Not sure if this is the most efficient way, but it works.


    protected override void OnBarUpdate()
    {
    if (CurrentBar == Count -1) //Current Bar Only
    {
    CandleOutlineColorSeries[0] = Color.LightGray;
    CandleOutlineColorSeries[1] = Color.Empty; //Resets previous bar to default
    BarColorSeries[0] = Color.LightGray;
    BarColorSeries[1] = Color.Empty; //Resets previous bar to default
    }
    }

    Comment


      #3
      Hello petermb,

      Thanks for your post(s) and welcome to the NinjaTrader forums!

      Your solution is the best.
      Paul H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by vpzdcv, Today, 02:31 AM
      0 responses
      8 views
      0 likes
      Last Post vpzdcv
      by vpzdcv
       
      Started by YevhenShynkarenko, Today, 01:22 AM
      0 responses
      16 views
      0 likes
      Last Post YevhenShynkarenko  
      Started by ttodua, Today, 12:52 AM
      0 responses
      7 views
      0 likes
      Last Post ttodua
      by ttodua
       
      Started by ttodua, Today, 12:50 AM
      0 responses
      6 views
      0 likes
      Last Post ttodua
      by ttodua
       
      Started by tvaughan4, Yesterday, 10:46 PM
      0 responses
      2 views
      0 likes
      Last Post tvaughan4  
      Working...
      X