Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plot color issue

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

    plot color issue

    I have an indicator that plots a line of something. The default color is yellow. There is an option to change the line color to green if the slope is up, and red if the slope is down. It works, unless the slope is zero, which it can be. That is the current value is equal to the previous value. In that case the color changes back to the default yellow.

    In the NT7 version, once the line color was changed, it would stay that color until a new change occurred, even if the there was no slope. That is, the default color did not come back. I don't understand the reason NT8 does not work this way.

    But in any case, I could fix the issue by adding another condition for the slope where if it is neither up nor down, then use the previous color. To do so I would need to use another variable that records the current color and then applies it when necessary. How would I do this?

    Here is the code I have now in the color section.

    PHP Code:
    slowSlope = Values[2];    // this is the line we are looking to change color
    
        if ( ColorMA == true && InvertColor == false )  // colors not inverted
                {
                    if ( IsRising(slowSlope) )    
                        { 
                            PlotBrushes[2][0] = Brushes.Green;  // slow ma in uptrend
                        }
                    else if ( IsFalling(slowSlope) ) 
                        {  
                            PlotBrushes[2][0] = Brushes.Red;  // slow ma in downtrend
                        }    
                            
                } 
    

    #2
    Hello bigtee,

    Thank you for the post.

    The fix you mentioned is what I would have suggested for this situation. Without seeing the NT7 logic I couldn't say why it works differently aside from the logic may be executing differently.

    The PlotBrushes[0][0] value is only for a single bar, so the condition would need to continue to be true for the length of bars you want to be colored or you would need to do as you said and use a variable.

    I look forward to being of further assistance.

    Comment


      #3
      Thanks for answer...

      You mention that PlotBrushes[0][0] is for one bar only. Is there a command to change the color for more than one bar or permanently?

      FYI... Here is the NT7 equivalent code. note I had to switch from Rising to IsRising in NT8 because Rising is not supported in NT8.

      PHP Code:
      if ( colorMA == true && invertColor == false )  // colors not inverted
                  {
                      if ( Rising(slowAve) )
                          { 
                              PlotColors[2][0] = Color.Green;  // slow ma in uptrend
                          }
                      else if ( Falling(slowAve) ) 
                          {  
                              PlotColors[2][0] = Color.Red;  // slow ma in downtrend
                          }                
                  } 
      
      Otherwise, can you please give an example of context in NT8 to record what the current color is in a variable, and then another context example of how to use that variable... eg..

      CurrColor = something (green or red)

      next time through would be
      PlotBrushes[0][0] = CurrColor or what?


      Thanks,
      bigtee

      Comment


        #4
        Hello,
        Thank you for the reply.

        Unfortunately, I could not tell from this region of code what the difference is, you would likely need to compare both files in total to see what the specific logical difference is.

        To use the previous set value, you could reference 1 BarsAgo of the PlotBrushes as you are setting it:

        Code:
        if(CurrentBar < 1) return;
        if (IsRising(Close))
             PlotBrushes[0][0] = Brushes.Blue;
        else if (IsFalling(Close))
             PlotBrushes[0][0] = Brushes.Red;
        else
             PlotBrushes[0][B][0][/B] = PlotBrushes[0][B][1][/B];
        PlotBrushes would reflect the BarsAgo you are referencing or [0] and [1] in the example above.

        To store a Brush as a variable, you could use the following:

        Code:
        private Brush myBrushVariable = Brushes.Red;
        later you can use it by name or myBrushVariable.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Thanks!

          referencing the PlotBrushes color from 1 bar ago did the trick.

          bigtee

          Comment

          Latest Posts

          Collapse

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