Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Initializing A New Brush and retrieving PlotBrush Color

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

    Initializing A New Brush and retrieving PlotBrush Color

    i am trying to get a plot from PlotBrushes

    Draw.Text(this,"T1","T1",5,dATRClose + tempATR*DT1Mult,Brushes.Red);

    I Tried

    Draw.Text(this,"T1","T1",5,dATRClose + tempATR*DT1Mult,PlotBrushes[3][0]);

    I did not get an error but It won't color.

    What I am trying to do is create a brush and get the color from PlotBrushes
    ///// this is where I am confused
    Brush tempBrush = new Brush();

    tempBrush = PlotBrushes[3][0];

    #2
    Hello,

    Thank you for the question.

    PlotBrushes would not return a brush if one has not been set yet using PlotBrushes.

    Have you at some point set a Brush for the plot in question using:
    Code:
    PlotBrushes[3][0] = someValue;
    If not, this is an optionally used collection meaning it contains nothing unless you set it and then the platform would use what you set rather than the plots defined brush for that bar.

    You would likely need to instead include the logic that sets the plot in the first place where you are trying to do this action or expose a plot from the indicator which signals when to change colors.


    I look forward to being of further assistance.

    Comment


      #3
      Retrieving Plot Brush Information

      AddPlot(new Stroke(Brushes.Gold, 2), PlotStyle.Hash, "Target1"); //5
      AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "Target2"); //6

      These were the original plots that were initialize. What I want to do is extract Brushes.Red so I can use it in my textbox.

      I thought I could create a new brush
      then

      brushname = PlotBrushes[1][0];

      Comment


        #4
        Hello,

        Thank you for clarifying.

        To use the same color as a plot, you can get what the plot was initially set to using:

        Code:
        Plots[0].Brush
        In your case if you have two total plots and the second is red, it would be:
        Code:
        Draw.Text(this,"T1","T1",5,dATRClose + tempATR*DT1Mult,[B]Plots[1].Brush[/B]);
        I look forward to being of further assistance.

        Comment


          #5
          Thanks

          I worked like a charm.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          73 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          152 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          100 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          288 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X