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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          173 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          91 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          129 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          208 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          186 views
          0 likes
          Last Post CarlTrading  
          Working...
          X