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 port119, Today, 02:43 PM
          0 responses
          1 view
          0 likes
          Last Post port119
          by port119
           
          Started by Philippe56140, Today, 02:35 PM
          0 responses
          2 views
          0 likes
          Last Post Philippe56140  
          Started by 00nevest, Today, 02:27 PM
          0 responses
          1 view
          0 likes
          Last Post 00nevest  
          Started by Jonafare, 12-06-2012, 03:48 PM
          5 responses
          3,986 views
          0 likes
          Last Post rene69851  
          Started by Fitspressorest, Today, 01:38 PM
          0 responses
          2 views
          0 likes
          Last Post Fitspressorest  
          Working...
          X