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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          83 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          45 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          65 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          68 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          57 views
          0 likes
          Last Post CarlTrading  
          Working...
          X