Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coloring Bars of a custom indicator

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

    Coloring Bars of a custom indicator

    Hi everyone

    I built a custom indicator and want to color positive bars green and nehative bars red.

    I wrote the following after Initialize():
    Add(new Plot(new Pen(Color.LimeGreen, 5), PlotStyle.Bar, "Up"));
    Add(
    new Plot(new Pen(Color.Red, 5), PlotStyle.Bar, "Down"));

    And after OnBarUpdate():

    if( Value[0] > 0 )
    BarColor = Color.LimeGreen;
    elseif( Value[0] < 0 )
    BarColor = Color.Red;

    My plot though is always green, also for negative values. Why?

    Thank you for help

    #2
    - You don't need to add plots
    - You want to check something like:

    if (Close[0] > Open[0])
    BarColor = Color.LimeGreen;
    else
    BarColor = Color.Red;
    RayNinjaTrader Customer Service

    Comment


      #3
      I took out the two lines of code to add plots, but in this way I get just a yellow line plotted (the default, I think).

      Comment


        #4
        See this tutorial for a similar concept.

        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        627 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        359 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        562 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        567 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X