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 wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          26 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, Yesterday, 09:53 PM
          2 responses
          49 views
          0 likes
          Last Post wzgy0920  
          Started by Kensonprib, 04-28-2021, 10:11 AM
          5 responses
          192 views
          0 likes
          Last Post Hasadafa  
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,234 views
          0 likes
          Last Post xiinteractive  
          Working...
          X