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

Multi-Color plot using PlotStyle.Bar

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

    Multi-Color plot using PlotStyle.Bar

    I am new to NinjaTrader and have made a simple SMA indicator using PlotStyle.Line ​that changes color based on it rising or falling. When using PlotStyle.Bar I can't get the color to change. How do you implement a multi-color bar?

    #2
    Hello spongeb0b,

    You can use PlotBrushes to color bar type plots. The sample from the help guide works for that type. This is also a simple way to demonstrate that just using the close price:

    Code:
    if (IsRising(Close))
        PlotBrushes[0][0] = Brushes.Blue;
    else if (IsFalling(Close))
       PlotBrushes[0][0] = Brushes.Red;
    else
       PlotBrushes[0][0] = Brushes.Yellow;



    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse, thank you for your response. I realized after reading my question again that I wasn't very clear about what I was asking. If you think of a line plot as a single contiguous line then the example code you gave changes it's color back and forth. In other words that single line can take on 3 different colors. I want to do the same thing for a single bar when the style is PlotStyle.Bar. So for example a single bar could take on 3 different colors. I am using OnEachTick and setting values and switching colors intrabar. What I'm noticing is that when I set a value for the plot a.k.a. bar and switch colors it just re-paints the entire bar with the last color set. If I set the bar to 25 and color it red, then set the bar to 50 and color it green, and set it to 75 and color it yellow, I want the same bar to show all 3 colors at the values they were set.

      Comment


        #4
        Hello spongeb0b,

        A single bar can only have one color, the plotbrushes changes the color for each of the plots datapoints in total.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse, I was afraid that was the case. Thank you so much for your help.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cre8able, Yesterday, 01:16 PM
          3 responses
          11 views
          0 likes
          Last Post cre8able  
          Started by ChartTourist, Today, 08:22 AM
          0 responses
          4 views
          0 likes
          Last Post ChartTourist  
          Started by LiamTwine, Today, 08:10 AM
          0 responses
          2 views
          0 likes
          Last Post LiamTwine  
          Started by Balage0922, Today, 07:38 AM
          0 responses
          5 views
          0 likes
          Last Post Balage0922  
          Started by JoMoon2024, Today, 06:56 AM
          0 responses
          6 views
          0 likes
          Last Post JoMoon2024  
          Working...
          X