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 sjsj2732, Today, 04:31 AM
          0 responses
          20 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          280 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          279 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          130 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          90 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X