Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot color according to bar close

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

    Plot color according to bar close

    I am building a volume indicator and I would like to Plot the color according to the close of the bar.

    The problem is that the plot is added to the intialize method which is called only once at the start of the program.

    Code:
    // variables
    Color MyColor = Color.Blue;
    
    // Initialize method
    Add(new Plot(new Pen(MyColor, 2), PlotStyle.Bar, "Volume"));
    
    //On Bar Update Method
    
    // logic here
    if(Close[0] > Open[0])
    MyColor = Color.Green;
    
    etc ....

    How can I make that works ?

    Thank you

    #2
    Hello,

    You can use BarColor to set the color of your volume bars. This will set the initial bar color to what is in Initialize, but will dynamically change to the 2nd bar color when that condition is true.

    Code:
    // variables
    Color MyColor = Color.Blue;
    Color MyColor2 = Color.Green;
    
    // Initialize method
    Add(new Plot(new Pen(MyColor, 2), PlotStyle.Bar, "Volume"));
    
    //On Bar Update Method
    
    // logic here
    if(Close[0] > Open[0])
    BarColor = MyColor2;
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi Matthew

      Thank you for your reply.

      If I do that it is coloring the Bars on the chart and not the volume bars appearing on the lower panel which is not what I want..
      Last edited by blar58; 07-17-2012, 11:48 AM.

      Comment


        #4
        Hello,

        Edit, sorry what you will want to do is PlotColors:



        Code:
        // logic here
        if(Close[0] > Open[0])
        PlotColors[0][0] = MyColor2;
        Last edited by NinjaTrader_Matthew; 07-17-2012, 11:56 AM.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Thank you very much Matthew

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 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
          548 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X