Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

BarColorSeries not working correctly in real time

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

    BarColorSeries not working correctly in real time

    Hi,

    I have the following code that when loading on historical data the BarColorSeries works perfectly however in real time it seems to keep coloring bars where the condition is not true any reason as to why this may be happening?

    Code:
    if(Highs[1][0] < CurrentDayOHL(BarsArray[1]).CurrentHigh[0]
    && Lows[1][0] > CurrentDayOHL(BarsArray[1]).CurrentLow[0]
    && Lows[2][0] == CurrentDayOHL(BarsArray[2]).CurrentLow[0])
    {
    BarColorSeries[0] = Color.Cyan;    
    }
                
    if(Highs[1][0] < CurrentDayOHL(BarsArray[1]).CurrentHigh[0]
    && Lows[1][0] > CurrentDayOHL(BarsArray[1]).CurrentLow[0]
    && Highs[2][0] == CurrentDayOHL(BarsArray[2]).CurrentHigh[0])
    {
    BarColorSeries[0] = Color.HotPink;    
    }
    Regards,
    suprsnipes

    #2
    Hello suprsnipes,

    Thank you for your post.

    You will need to set a BarColorSeries for when these conditions are not true such as the following:
    Code:
    if(Highs[1][0] < CurrentDayOHL(BarsArray[1]).CurrentHigh[0]
    && Lows[1][0] > CurrentDayOHL(BarsArray[1]).CurrentLow[0]
    && Lows[2][0] == CurrentDayOHL(BarsArray[2]).CurrentLow[0])
    {
    BarColorSeries[0] = Color.Cyan;    
    }
                
    [B]else if([/B]Highs[1][0] < CurrentDayOHL(BarsArray[1]).CurrentHigh[0]
    && Lows[1][0] > CurrentDayOHL(BarsArray[1]).CurrentLow[0]
    && Highs[2][0] == CurrentDayOHL(BarsArray[2]).CurrentHigh[0])
    {
    BarColorSeries[0] = Color.HotPink;    
    }
    
    [B]else[/B]
    {
    BarColorSeries[0] = Color.Black;
    }
    Please let me know if you have any questions.

    Comment


      #3
      Thanks Patrick.

      Comment


        #4
        Hi,

        I am still having problems where the BarColorSeries does not color the bar correctly in real time. I am using a basic indicator and I'm not quite sure why the bars are not correcly updated as per the code and find when I reload Ninjascript the bars are colored correctly.

        This is my code;

        Code:
        protected override void Initialize()
        {
        Add(symbol1, PeriodType.Minute,1);
        Add(symbol2, PeriodType.Minute,1);
        
        CalculateOnBarClose = true;
        Overlay                = true;    
        }
        
        protected override void OnBarUpdate()
        {
        if(Highs[1][1] < CurrentDayOHL(BarsArray[1]).CurrentHigh[1]
        && Lows[1][1] > CurrentDayOHL(BarsArray[1]).CurrentLow[1]    
        && Lows[2][1] == CurrentDayOHL(BarsArray[2]).CurrentLow[1])
        {
        BarColorSeries[1] = Color.Olive;    
        }
        
        else if(Highs[1][1] < CurrentDayOHL(BarsArray[1]).CurrentHigh[1]
        && Lows[1][1] > CurrentDayOHL(BarsArray[1]).CurrentLow[1]    
        && Highs[2][1] == CurrentDayOHL(BarsArray[2]).CurrentHigh[1])
        {
        BarColorSeries[1] = Color.Gray;    
        }
                    
        else
        {
        BarColorSeries[1] = Color.Blue;    
        }
        
        }
        Regards,
        suprsnipes
        Last edited by suprsnipes; 07-30-2013, 08:40 PM.

        Comment


          #5
          Hello suprsnipes,

          Thank you for your response.

          Can you attach your indicator .cs file to your response so I may investigate this matter further on my end?

          You will find the indicator in the following directory on your PC: (My) Documents\NinjaTrader 7\bin\Custom\Indicator

          I look forward to your response.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Balage0922, Today, 07:38 AM
          0 responses
          1 view
          0 likes
          Last Post Balage0922  
          Started by JoMoon2024, Today, 06:56 AM
          0 responses
          6 views
          0 likes
          Last Post JoMoon2024  
          Started by Haiasi, 04-25-2024, 06:53 PM
          2 responses
          19 views
          0 likes
          Last Post Massinisa  
          Started by Creamers, Today, 05:32 AM
          0 responses
          6 views
          0 likes
          Last Post Creamers  
          Started by Segwin, 05-07-2018, 02:15 PM
          12 responses
          1,786 views
          0 likes
          Last Post Leafcutter  
          Working...
          X