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

Bar colors

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

    Bar colors

    Hello...

    Is it possible to make code that would change the bar color from red to green based on indicator input, such as MFI?

    #2
    Crimsonite,

    Yes, this is possible. Something like the following example would work.

    if( Rising(MFI(14) )
    {
    PlotColors[X][Y] = Color.Blue;
    }

    X is which plot you want, 0 being the first one added. The Y is the bar, and generally is recommended to be 0 unless you want to repaint.

    You can set whatever conditions you want in the if statements to change the colors.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Custom bar type color change

      Im using a custom bar type (SiProRenko from Shark Indicators). Is it possible to change the bar color depending on a certain condition in Ninja 7?

      The PlotColors() method does not seem to work.


      Originally posted by NinjaTrader_AdamP View Post
      Crimsonite,

      Yes, this is possible. Something like the following example would work.

      if( Rising(MFI(14) )
      {
      PlotColors[X][Y] = Color.Blue;
      }

      X is which plot you want, 0 being the first one added. The Y is the bar, and generally is recommended to be 0 unless you want to repaint.

      You can set whatever conditions you want in the if statements to change the colors.

      Please let me know if I may assist further.

      Comment


        #4
        Hello mballagan,

        Yes it would be possible to change the color of a bar in NinjaTrader 7 when a certain condition is met.
        You would use, BarColor=Color.Red, under the condition.

        For example under OnBarUpdate()

        if(CurrentBar<1) return; //Checks to make sure enough bars exist on chart.

        if(Close[0]>Close[1]) //If Close of this bar is above last
        {
        BarColor = Color.Red; //Set that bar to a color or red if the above is true.
        }

        See BarColor section of our helpguide:


        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          BarColorSeries

          Thanks.

          This also works:

          // Sets the color of the current bar to blue.
          BarColorSeries[0] = Color.Blue;

          // Sets the color of the previous bar to orange.
          BarColorSeries[1] = Color.Orange;

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by frankthearm, Yesterday, 09:08 AM
          14 responses
          47 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by gentlebenthebear, Today, 01:30 AM
          2 responses
          13 views
          0 likes
          Last Post gentlebenthebear  
          Started by Kaledus, Today, 01:29 PM
          2 responses
          8 views
          0 likes
          Last Post Kaledus
          by Kaledus
           
          Started by PaulMohn, Today, 12:36 PM
          2 responses
          16 views
          0 likes
          Last Post PaulMohn  
          Started by Conceptzx, 10-11-2022, 06:38 AM
          2 responses
          56 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Working...
          X