Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Dynamic Color Not Working

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

    Indicator Dynamic Color Not Working

    Hi, two issues that need your help:

    1. I created a new supertrend indicator that plots the line in different colors based on the CCI level. If CCI is greater than zero, color is set to green; if less than zero, color is red; if zero, color is yellow However, when I displayed the indicator line on the chart, it always shows green color. Any idea? See attached code.

    2. Separately, I created a strategy that added the above custom indicator. When I run the strategy in the chart, the indicator line is not shown at all.

    Please advise.
    Attached Files

    #2
    Hello soloaudio,

    Welcome to the NinjaTrader Support Forums!

    I see inside of your Indicator that you are defining a "public DataSeries Direction" inside of the Properties but you are not declaring it inside of the Indicator. You will want to declare it inside of the Indicator itself. Note that if you do not want to plot then you may use the color Transparent.

    I believe the same issue is going to be with your Strategy as well.

    Let us know how that works out for you.
    Last edited by NinjaTrader_JC; 06-21-2013, 11:19 AM.
    JCNinjaTrader Customer Service

    Comment


      #3
      JC,

      1. The coloring of "Trend" works fine after I added the line below. Didn't know the second indicator plot ("Direction") had to be included even though I don't need to plot it. Any reason?

      Add(new Plot(Color.Transparent, PlotStyle.Line, "Direction"));


      2. The strategy is able to show the Trend indicator plot once the strategy has been enabled. I thought the plot would be available immediately after the strategy is added to the chart but that's not the case..

      Thanks.
      Last edited by soloaudio; 06-21-2013, 09:18 AM.

      Comment


        #4
        Originally posted by soloaudio View Post
        JC,

        1. The coloring of "Trend" works fine after I added the line below. Didn't know the second indicator plot ("Direction") had to be included even though I don't need to plot it. Any reason?

        Add(new Plot(Color.Transparent, PlotStyle.Line, "Direction"));


        2. The strategy is able to show the Trend indicator plot once the strategy has been enabled. I thought the plot would be available immediately after the strategy is added to the chart but that's not the case..

        Thanks.
        You should probably see an error in your log, resulting from trying to access the undeclared object in the Values array.

        Comment


          #5
          Hello soloaudio,

          Running your code since you have a "try-catch" it appears that is is plotting the correct values of the lines but when you try to call "Direction.Set()" NinjaTrader does not have a declared value for this and goes into the "catch" statement which skips over the PlotColors.

          It is always important to declare and set/initialize objects before trying to access or modify any code to ensure proper values.
          JCNinjaTrader Customer Service

          Comment


            #6
            Thanks very much!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            627 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            359 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
            562 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            567 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X