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

How do I change the bar color in a custom bar type

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

    How do I change the bar color in a custom bar type

    I created a custom bar type based on the original RenkoBars type, where I show the wicks.
    That's working fine, but now I want to change the bar color based on some conditions.
    In the OnDataPoint override I'm trying to do that with BarBrush or BarBrushes[0], but I get a compile error stating "The name BarBrush does not exist in the current context".
    How can I achieve it?

    #2
    Hello wjadevries,

    Thank you for your post.

    OnDataPoint is used to define how the bar is built. The OnDataPoint() method is where you should adjust data points (bar values) of your series.

    BarBrush is specific to indicators and strategies. To present bars information in a different visual representation, you could color the bars within an Indicator or by using ChartStyles. When using ChartStyles, the DownBrush and UpBrush can be used to set the color of the bar from the chart style.

    Please see the following help guide links about working with custom Brushes and using ChartStyles.

    Working with Custom Brushes - https://ninjatrader.com/support/help...gcustombrushes
    ChartStyles - https://ninjatrader.com/support/help...hart_style.htm

    Let us know if we may further assist.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      If I understand correctly I can't use chartsyles in a script to set bar colors individually based on a condition?
      So I need to create a separate indicator for it?

      Comment


        #4
        Hello wjadevries,

        Thank you for your note.

        BarBrush can be used in a Strategy or an Indicator to change the color of a bar. Please note that this cannot be set in a BarsType.

        ChartStyles can also be used to change the color of a bar when modifying UpBrush or DownBrush properties of the ChartStyle.

        Please see the attached example strategy, ChangeBarColors, for how BarBrush, UpBrush, and DownBrush may be used.

        Here is a help guide link about BarBrush - https://ninjatrader.com/support/help.../?barbrush.htm

        Please let us know if we may assist further.
        Attached Files
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Thanks for your explanation.
          Already created an indicator for it and that works fine.
          Cheers!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by wuannetraam, Today, 02:40 AM
          0 responses
          6 views
          0 likes
          Last Post wuannetraam  
          Started by cyberpete76, 03-27-2023, 12:29 AM
          7 responses
          268 views
          1 like
          Last Post slightly  
          Started by renewsaltwater, Today, 01:15 AM
          0 responses
          2 views
          0 likes
          Last Post renewsaltwater  
          Started by slightly, Today, 12:49 AM
          0 responses
          4 views
          0 likes
          Last Post slightly  
          Started by sdauteuil, 09-23-2021, 10:16 AM
          4 responses
          1,211 views
          0 likes
          Last Post jacobpescaia44  
          Working...
          X