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

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 rajendrasubedi2023, Today, 09:50 AM
              0 responses
              9 views
              0 likes
              Last Post rajendrasubedi2023  
              Started by ender_wiggum, Today, 09:50 AM
              0 responses
              4 views
              0 likes
              Last Post ender_wiggum  
              Started by bmartz, Today, 09:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by geddyisodin, Today, 05:20 AM
              3 responses
              24 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by lorem, Today, 09:18 AM
              1 response
              5 views
              0 likes
              Last Post lorem
              by lorem
               
              Working...
              X