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

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 gemify, 11-11-2022, 11:52 AM
            6 responses
            803 views
            2 likes
            Last Post ultls
            by ultls
             
            Started by ScottWalsh, Today, 04:52 PM
            0 responses
            3 views
            0 likes
            Last Post ScottWalsh  
            Started by ScottWalsh, Today, 04:29 PM
            0 responses
            7 views
            0 likes
            Last Post ScottWalsh  
            Started by rtwave, 04-12-2024, 09:30 AM
            2 responses
            22 views
            0 likes
            Last Post rtwave
            by rtwave
             
            Started by tsantospinto, 04-12-2024, 07:04 PM
            5 responses
            70 views
            0 likes
            Last Post tsantospinto  
            Working...
            X