Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simplest Way to Determine the Slope of an Indicator and Color Code as Green or Red?

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

    Simplest Way to Determine the Slope of an Indicator and Color Code as Green or Red?

    Dear NT8 Indicator Forum,

    I am just starting learning Ninjascript and successfully code a few indicators. My next one is color coding my Stochastics indicator (%D to be specific) - if %D is rising I want to color it Green and if %D is falling I want to color the line Red.

    If I didn't have the benefit of asking this Forum, my defacto would be a simple compare of 2 points, e.g., to check for rising %D[0] > %D[1] and vice versa for falling %D[0] < %D[1]. Thinkorswim has a simple check "if rising...." or "if falling" and you're done.

    Is there a standard way of checking slope? Also I wanted my indicator to have more sophistication, e.g., how do tell if market is consolidating? I would paint a different color for that scenario, although this would be Part 2 of this activity.

    If anyone has a snippet to help in this post, kindly paste here.

    Thanks in advance!

    #2
    Hello brother Please contact me i can help you make them in color thanks

    Comment


      #3
      you can use this one
      if(D[0] > D[1] )
      PlotBrushes[0][0] = Brushes.Green
      else
      PlotBrushes[0][0] = Brushes.Red

      Comment


        #4
        Hello aguison,

        To know if the price is rising or falling you can use the methods IsRising and IsFalling, that is essentially the same as the code posted in #3 of this thread, based on that output you could color a bar or make a drawing. If you wanted to determine the slope using a value you can also use the Slope function




        Comment


          #5
          oh man! ajgaus13 and Jesse: Thank you so much! Here's what the Indicator looks like: Stochastics %D is now colored based on plot conditions:
          Attached Files
          Last edited by aguison; 07-01-2024, 09:10 AM.

          Comment

          Latest Posts

          Collapse

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