• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.

        http://www.ninjatrader-support.com/H...V6/SetUp2.html
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by hiikila, Today, 02:40 AM
        0 responses
        1 view
        0 likes
        Last Post hiikila
        by hiikila
         
        Started by Beauregard, Yesterday, 11:50 PM
        0 responses
        12 views
        0 likes
        Last Post Beauregard  
        Started by renkodan, Yesterday, 11:56 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by J_o_s, 04-04-2020, 11:17 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by thetickfarmer, 04-04-2020, 04:44 PM
        2 responses
        20 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X