Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          30 views
          0 likes
          Last Post ageeholdings  
          Started by reynoldsn, Today, 02:34 PM
          0 responses
          6 views
          0 likes
          Last Post reynoldsn  
          Started by nightstalker, Today, 02:05 PM
          0 responses
          10 views
          0 likes
          Last Post nightstalker  
          Started by llanqui, Yesterday, 09:59 AM
          8 responses
          29 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by quicksandatl, Today, 01:39 PM
          1 response
          6 views
          0 likes
          Last Post quicksandatl  
          Working...
          X