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

re: Get Bar Color

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

    re: Get Bar Color

    Hello,
    How can I get the bar color for the last bar plotted?
    I have a vendor indicator that plots the last bar a certain color when a condition is triggered.
    The vendor is unwilling to make the condition info available in a script.
    I would like to access the color of last bar plotted in my own script to decide if I want to take action.

    #2
    Hello saturntd,

    Thank you for your post.

    You could try checking the Indicator.BarBrushes collection for the color of the bar x bars ago, however we recommend using the same logic the indicator does.

    BarBrushes - https://ninjatrader.com/support/help...barbrushes.htm

    You could use a condition for determining the previous bar's color. If previous close greater than previous open then the bar was green. If previous close less than previous open then the bar was red.

    Please let me know if you have any other questions.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Thanks for responding Gaby.
      Unfortunately, BarBrushes[0] doesn't show any colors.
      If I check like this: if(BarBrushes[0] == Brushes.Yellow) ...
      It never finds the color I'm looking for.
      I even tried looping back 10 bars for each new bar & it doesn't find anything either.
      Is there some other way to get the bar colors?

      Comment


        #4
        I think what I would do, if I were you, is to get the COLOR of the bar brush e.g. Color myColor = ((SolidColorBrush)myIndicator.BarBrushes[0]).Color. Then, add a plot or print statement to dump the RGB values of myColor e.g. Print(myColor.R + " " + myColor.G + " " + myColor.B); and that should give you an idea how to proceed. The values will either be there or they will not be there. If they are there, you'll know what to compare with. It could be that the brush INSTANCES are not equal because they're cloned, or they differ in opacity/alpha, or whatever, but the color is what it is. Let us know if this approach yields you the data you are looking for. It could also be that the vendor has hidden this information and is not really using BarBrushes even though it looks like they are - they could be painting the bars themselves in OnRender from a private series.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Hello,

          QuantKey_Bruce has provided some good information. I agree with the approach he is recommending since you don't have access to the logic that the other indicator is using to change the bar color.
          Gaby V.NinjaTrader Customer Service

          Comment


            #6
            Thanks Bruce & Gaby.
            Still couldn't get it to work.
            Not going to worry about it anymore.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,404 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by Shai Samuel, 07-02-2022, 02:46 PM
            4 responses
            95 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by DJ888, Yesterday, 10:57 PM
            0 responses
            8 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            159 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Yesterday, 09:29 PM
            0 responses
            8 views
            0 likes
            Last Post Belfortbucks  
            Working...
            X