Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Could someone Comment on Coloring Bars for One dataSeries

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

    Could someone Comment on Coloring Bars for One dataSeries

    I tried this to no Avail

    protected override void OnBarUpdate()
    {
    if (BarsInProgress==2 )
    {
    if (Close[0] > Close[1]) boxColor = Brushes.Blue;
    if (Close[0] < Close[1]) boxColor = Brushes.Red;

    BarBrush.Freeze();
    BarBrush=boxColor;

    }
    }

    It gives an index error as it seems to be expecting an index to the bar you are coloring

    PlotBrushes[0][0] works fine this way for setting the color and opacity. But what is the Analog to coloring the price bars and setting the opacity of the price bars of a particular data series bar.

    ~J

    #2
    Hello JerryWar,

    Thank you for your post.

    Are you trying to color the bars for the secondary bar series?

    What line are you getting an indexing error on? Or is this in the Log tab?

    Comment


      #3
      Originally posted by JerryWar View Post
      I tried this to no Avail

      protected override void OnBarUpdate()
      {
      if (BarsInProgress==2 )
      {
      if (Close[0] > Close[1]) boxColor = Brushes.Blue;
      if (Close[0] < Close[1]) boxColor = Brushes.Red;

      BarBrush.Freeze();
      BarBrush=boxColor;

      }
      }

      It gives an index error as it seems to be expecting an index to the bar you are coloring

      PlotBrushes[0][0] works fine this way for setting the color and opacity. But what is the Analog to coloring the price bars and setting the opacity of the price bars of a particular data series bar.

      ~J
      You have left out a CurrentBars check.

      Comment


        #4
        Originally posted by NinjaTrader_PatrickH View Post
        Hello JerryWar,

        Thank you for your post.

        Are you trying to color the bars for the secondary bar series?

        What line are you getting an indexing error on? Or is this in the Log tab?

        1) Yes it was originally the secondary bar Series but I realized there may another problem with that. As I could only access a Secondary Series when it was added within the indicator. i.e. If it was added manually on the chart , BarsInProgress could not see it. and if added within the indicator the series is Invisible. So I switched to the Primary Series Just to get the Bar Color Working.
        2) Error on Calling 'OnBarupdate' method on Bar 76. Object reference not set to an instance of an object.
        This is what led me to believe it was an index issue.
        3) I added currentbars>BarsRequired to Plot as koganam suggested. That did not fix the issue either.

        J~
        Last edited by JerryWar; 06-21-2015, 10:21 AM.

        Comment


          #5
          Yes I did overlook that. When your playing with new Toys sometimes you leave out the common sense things. However it did not make a difference.

          Thanks
          J~

          Comment


            #6
            I did Get the following to work partially.

            protected override void OnBarUpdate()
            {
            if (CurrentBars[0] < BarsRequiredToPlot) return;

            if (Close[0] > Close[1]) boxColor = (Brushes.Blue);
            if (Close[0] < Close[1]) boxColor = (Brushes.Red);

            BarBrush=boxColor;

            }

            The problem is for multiple data Series it changes the brush for all DataSeries with compression >= the DataSeries to which the indicator is applied Even when the code is modified to use BarsInProgress and access closes of a specific series you can't seem to set the Brush for a Specific DataSeries. So I guess changing the opacity in this way is also out of the question.

            ~J

            Comment


              #7
              Originally posted by JerryWar View Post
              I did Get the following to work partially.

              protected override void OnBarUpdate()
              {
              if (CurrentBars[0] < BarsRequiredToPlot) return;

              if (Close[0] > Close[1]) boxColor = (Brushes.Blue);
              if (Close[0] < Close[1]) boxColor = (Brushes.Red);

              BarBrush=boxColor;

              }

              The problem is for multiple data Series it changes the brush for all DataSeries with compression >= the DataSeries to which the indicator is applied Even when the code is modified to use BarsInProgress and access closes of a specific series you can't seem to set the Brush for a Specific DataSeries. So I guess changing the opacity in this way is also out of the question.

              ~J
              A bit unsure of what you are trying to do, but what you have written will change the barColor for all barSeries.

              You want to either filter using BarsInProgress or the barSeries array, [I]Closes.

              Comment


                #8
                Hello JerryWar,

                Were you able to get the code working as intended?

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello JerryWar,

                  Were you able to get the code working as intended?

                  No, In my opinion the NT8 BarBrush does not work properly on Multiple Data Series.
                  Whether it was Color , Opacity or setting it transparent or whatever I was not able to limit its effect to the intended DataSeries. So I was forced to give up on the Conversion of my NT7 code to NT8 as I have to be able to color a bar of a data series on condition differently from the rest. All my code is multiple based on Multiple dataSeries so I figured I was swimming up stream against the current at this point.

                  J~

                  Comment


                    #10
                    Koganam, Thanks but it simply doesn't work. I was filtering by BarsInProgress.

                    Comment


                      #11
                      Hello JerryWar,

                      Thank you for your response.

                      You would only be able to color the primary bar series using BarBrushes.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by andrewtrades, Today, 04:57 PM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by chbruno, Today, 04:10 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post chbruno
                      by chbruno
                       
                      Started by josh18955, 03-25-2023, 11:16 AM
                      6 responses
                      436 views
                      0 likes
                      Last Post Delerium  
                      Started by FAQtrader, Today, 03:35 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post FAQtrader  
                      Started by rocketman7, Today, 09:41 AM
                      5 responses
                      19 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Working...
                      X