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 llanqui, Today, 03:53 AM
          0 responses
          5 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          10 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          15 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          14 views
          0 likes
          Last Post strategist007  
          Working...
          X