Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Color Change Indicator

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

    Color Change Indicator

    Hi,

    I wrote a code for having my momentum indicator be green/red/white when it is sloping up / down / uncertain (with some criteria).

    Anyway, I am using 3 different plots, and connecting them by the same code as in the example simple moving average with changing colors somewhere I found in these forums before.

    But the thing is, when colors are changing (while the indicator is switching to a new plot), the color of the indicator for the previous bar is also changed to say green from red, along with the current bar - in the connection process.

    When colors are constantly changing, it really annoys me even though it is not so important.

    I tried not assigning a value to the new plot for the previous bar (differently from the example color change indicator does), but then the previous bar has no plot at all where the color is changing - it is simply empty.

    I don't know if there is another way of writing the code so this won't be a problem - if it is, please show me how.

    If not possible, I had a different idea: instead of using 3 different plots of different colors, may be I could use only one plot, and then a different indicator to paint each bar - like heiken ashi - but for the indicator's bars instead of the markets bars - Is this possible?

    Thank you

    #2
    Hi zaza5000,

    I have a response to your request, which I need to confirm with a colleague.

    I will reply shortly.
    TimNinjaTrader Customer Service

    Comment


      #3
      I mean only solution I have is, make the plots' styles bar, instead of line, and then not set the previous bar's value for connecting, and it looks fine - just like the VolumeUpDown indicator.

      But I like the line plot style better - and I couldn't figure out a solution.

      Comment


        #4
        Hi zaza5000,

        With NinjaTrader 6.5, that behavior is expected with CalculateOnBarClose = false.

        However, please review the following thread to see how this has been addressed in NinjaTrader 7 - http://www.ninjatrader.com/support/f...ad.php?t=21225
        TimNinjaTrader Customer Service

        Comment


          #5
          I see, it's a nice feature of NT 7 amongst many others.

          But by the way, it has nothing to do with calculate on bar close = false/true:

          because after the bar closes, say the color is green, because it was sloping up.

          after the bar after that closes, say it started sloping down - then the previous bar's color should remain green, and the new one should be red, but instead, what happens is both the previous and the new bars become red.

          If the code is not written that way, and plot syle is line, the previous bar's value is deleted and there's empty spot.

          ------

          anyway, i'll just look at my momentum indicator with plot style - bar, instead of line until NT 7 is released =)

          Comment


            #6
            use PlotColors[][] in NT7

            Comment


              #7
              You should only connect the current plot to the prior value of the plot when plotting lines. Here's the idea of how the code should look, where items between "<" and ">" need to be replaced by real code and "n" needs to be replaced by the correct subscript for the plot in the Plots collection:

              YourPlot.Set( <your data value>[0] );
              if( Plots[n].PlotStyle == PlotStyle.Line )
              YourPlot.Set( 1, <your data value>[1] );

              Comment

              Latest Posts

              Collapse

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