Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarColorSeries & CandleOutlineColorSeries timing

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

    BarColorSeries & CandleOutlineColorSeries timing

    Since these are documented, and since the NT V7 Heiken indicator uses them, I presume they are supported. Unfortunately, the documentation says noting about the *timing* of when they are valid.

    The Heiken indicator sets their contents to Color.Transparent in OnBarUpdate(). How does it know that is the right time? Could it just iterate over them in OnStartUp()? How about at the start of Plot()?

    It seems to me that they need to get set transparent after they have been set up for plotting, but before they actually get used to plot. How do I know enough to arrange that?

    --EV

    #2
    Hello,

    With OnBarUpdate() this does iterate on each bar and set each bar to this color. Each bar can have a different color. Therefor it is required to have this in OnBarUpdate().

    Would recommend adding it before you set your Plot.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Would this be the correct model:
      • For each bar
        • The system calls OnBarUpdate() for each data plot
        • Then the system calls OnBarUpdate() for each indicator

      • Then the system calls Plot() or each data plot
      • Then the system calls Plot() for each indicator

      That would mean that filling BarColorSeries needs to be done by the last bar of OnBarUpdate(), and that trying to do it in Plot() would be too late -- it would have already been used to plot the bars.

      Couldn't I just iterate ( 0 to BarColorSeries.Count-1) or (0 to Bars.Count-1), filling it with Color.Transparent? The Heiken indicator does it bar by bar, but there is a certain amount of calculation to find the index for each bar. It seems simpler and more efficient to just pick a time -- first bar or last bar -- and blast it full of Color.Transparent.

      Any reason not to do that?

      --EV

      Comment


        #4
        Hello,
        • The chart data is loaded internally
        • Then the system calls OnBarUpdate() for each indicator starting from bar1
        • Then the system calls Plot() for each indicator once the data series are done populating and displays the data.
        This is all dont before output to the screen.

        When you start an indicator OnBarUpdate always starts at bar 1 and goes through each bar until the current bar.

        Therefor

        OnBarUpdate()
        {

        BarColor = Color.Transparent;

        }

        Will set the entire chart transparent.

        What your refercing to using BarColorSeries is also another way to do it. However why take the extra time and processing power to iterate back on the data when you could have done this on the first iteration starting from bar 1 with OnBarUpdate?

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          The iterating idea came because what the Heiken indicator is doing is the following two lines each time through OnBarUpdate(). It seems more efficient to just blindly fill the whole array at the proper time.

          Code:
          BarColorSeries.Set(Math.Max(0, CurrentBar + Math.Max(0, Displacement) + (CalculateOnBarClose ? 1 : 0)), Color.Transparent);
           CandleOutlineColorSeries.Set(Math.Max(0, CurrentBar + Math.Max(0, Displacement) + (CalculateOnBarClose ? 1 : 0)), Color.Transparent);
          -EV

          Comment


            #6
            I should add that there is a complication.

            I need to save the current color, set the bar transparent, and then I may need to restore the color later on.

            For example, assume that I am plotting Heiken Ashi candlesticks on the chart. I need to set the original bars transparent so they do not conflict with my HA plot. Then, if the user reconfigures to move the HA indicator to an indicator panel, I need to restore the user colors so that the main plot will re-appear.

            --EV

            Comment


              #7
              What is BarColorSeries (semantically)?

              It does not seem to have real colors when it gets to me. Is it kind of a PlotColors for the chart bars?

              Can I fill it with Color.Transparent, and then when I want the user bars to show again just call BarColorSeries.Reset()?

              --EV

              Comment


                #8
                Hello,

                No need to store the users bar color in this case.

                You would just not call BarColorSeries if the user does not want the oringal chart bars transparent. As the main chart bar colors are always used unless you override them with either BarColor or BarColorSeries.

                Let me know if I can be of further assistance.
                BrettNinjaTrader Product Management

                Comment


                  #9
                  Are you saying that BarColorSeries starts over each time a new series of calls to OnBarUpdate() is initiated?

                  Is it right to think of BarColorSeries as an override on the bar color, much as PlotColors is an override on an indicator's colors?

                  Does each indicator get a BarColorSeries to work with? If not, how do indicators keep from stepping on each other? If they do get separate ones, then how do you decide who wins?

                  In other words, just exactly what id BarColorSeries from an architectural point of view?

                  --EV

                  Comment


                    #10
                    Are you saying that BarColorSeries starts over each time a new series of calls to OnBarUpdate() is initiated?


                    Yes it can.

                    Does each indicator get a BarColorSeries to work with? If not, how do indicators keep from stepping on each other? If they do get separate ones, then how do you decide who wins?


                    Yes you can have this occur, last one to apply wins which is the last indicator on the list.


                    Bars get loaded into the chart with the color the user chose in the data series window.

                    At that time the indicators are loaded, if an indicator then overrides the original color it does so and overrights the property for that bar.

                    Let me know if I can be of further assistance.
                    BrettNinjaTrader Product Management

                    Comment


                      #11
                      Originally posted by NinjaTrader_Brett View Post
                      Are you saying that BarColorSeries starts over each time a new series of calls to OnBarUpdate() is initiated?

                      Yes it can.

                      It can, or it does? "It can" sounds as if it does sometimes, but not other times. Can I depend on it being reset at the start of each series of calls to OnBarUpdate?

                      Comment


                        #12
                        Yes It Can was said as this depends on how you code it.

                        Suggest not iterating through all the previous bars though with BarColorSeries. Suggest just setting each bar with BarColor in the initial OnBarUpdate(). This way you dont have to worrie about looping through previous bars to set them to transparent at the end of the chart creation. This is actually a bad approach as this will run on each new tick or bar close. Which you dont want the bar color resetting to transparent on all bars on the chart with every new tick. Then you would need to use this approach anyways on new bars that are formed.

                        BarColor was created to make this easier to do.

                        You want to set it once on first bar run through.
                        BrettNinjaTrader Product Management

                        Comment


                          #13
                          > Yes It Can was said as this depends on how you code it.

                          So whether or not BarColorSeries is reset before each tim OnBarUpdate() is called with CurrrentBar==0 depends on how the indicator is coded? How so?

                          > Suggest not iterating through all the previous bars though with BarColorSeries. Suggest just setting each bar with BarColor in the initial OnBarUpdate().

                          What is "the initial OnBarUpdate()" ?

                          >This way you dont have to worrie about looping through previous bars to set them to transparent at the end of the chart creation.

                          What is "the end of chart creation"? When CurrentBar==LastBarIndexPainted?

                          >This is actually a bad approach as this will run on each new tick or bar close.

                          I have only run on EOD data so far, so all I have seen is sequences of calls to OnBarUpdate() that run from CuurentBar==0 to CurrentBar==LastBarIndexPainted. Are you saying that with a live feed, OnBarUpdate() will be called for just the last bar as each new bar becomes available, rather than getting called for all bars whenever anything changes, as I have seen so far?

                          > BarColor was created to make this easier to do.

                          Does that take into account the indexing that was in the code that I included earlier? Are you saying that the NT released Heiken indicator should just change their more complicated code to using BarColor?

                          >You want to set it once on first bar run through.
                          What is "first bar run through"?

                          --EV
                          Last edited by ETFVoyageur; 01-13-2011, 02:38 PM.

                          Comment


                            #14
                            Hello,

                            Misunderstood me on the first point. Has to do with is you code using BarColor or BarColorSeries. Bar colors are always reset when the indicator is removed, or disabled.


                            What is "the end of chart creation"? When CurrentBar==LastBarIndexPainted?

                            Yes, or a better way to describe this if

                            if(!Historical)

                            Historical data is when all OnBarUpdates() are run through on the inital enable of the indicator. After that as bar data comes in OnBarUpdate() gets called for either each new tick or each new bar depending on if your running Calculate On Bar Close = True or False. This answers your last question on intial run through, intial run through is historical data.

                            Does that take into account the indexing that was in the code that I included earlier? Are you saying that the NT released Heiken indicator should just change their more complicated code to using BarColor?

                            Yes this most likely could have been done. Though I believe BarColor was most likely created after this was.

                            Let me know if I can be of further assistance.
                            BrettNinjaTrader Product Management

                            Comment


                              #15
                              OK -- I have tried what you suggest, and it works about as well as what I was doing. It is certainly simpler, though, so I like it. (I still do not feel that I thoroughly understand what is happening though, and I want to.)

                              There is a problem, though -- the one I discovered this morning that set me off on all of this. Let me tell you what I am doing and perhaps you have a suggestion. The issue is that in my enhanced Heiken Ashi indicator, the user can have the plot be either on the main chart or in an indicator panel. Since, according to earlier discussions, there is no way for the indicator to detect which place it is running, I provide a configuration enum for the user to tell the indicator which place it is running.

                              In OnStartUp(), I detect whether or not the indicator will need the user's charting to be suppressed (i.e. made transparent). To keep it simple, consider just two cases -- if drawing the candlesticks in the main chart, then the user's other price charting needs to be suppressed. If drawing the candlesticks in an indicator panel, then the user's price charting should remain visible. OnStartUp() checks to see which is happening and sets a boolean, bNeedsTransparency

                              In OnBarUpdate(), I now have the lines

                              Code:
                                          //  Override the user's colors.  This is just an override, so no saving and restoring is needed.
                                          if (bNeedsTransparency) BarColor = Color.Transparent;
                              OK -- now if I start with a fresh chart and add the indicator, I can switch it back and forth and all works fine. If I have the indicator displaying in an indicator panel and I save that as a chart template, then reloading the template is fine -- I can continue on and switch back and forth between display areas just fine.

                              However, if I have the indicator displaying on the main chart and save it as a template, then when I reload it and switch the indicator display to an indicator panel no user price chart shows up. I have verified that OnStartUp() is setting bNeedsTransparency correctly.

                              It is as if transparency of user plot had gotten hard-coded in when saved as a template.

                              Any ideas how I should go from here? What I should be looking for?

                              What is different about getting in a situation (and things work) from saving that as a template and then when you reload the template things do not work?

                              --EV

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              607 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              353 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              105 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              560 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              561 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X