Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD Histogram Colour

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

    MACD Histogram Colour

    Hello,

    I was wondering if it's possible in NT7 to colour the MACD Histogram so it's Green for Bullish and Red for Bearish. Currently it's just Blue but I would like it to change depending on market conditions.

    Thanks

    #2
    Hello Ninj4Man,

    This is easy to do in a custom indicator with the sample code in this section of the help guide,

    Originally posted by http://ninjatrader.com/support/helpGuides/nt7/?plotcolors.htm
    // Color the Upper plot based on plot value conditions
    if (Rising(Upper))
    PlotColors[0][0] = Color.Blue;

    else if (Falling(Upper))
    PlotColors[0][0] = Color.Red;
    else
    PlotColors[0][0] = Color.Yellow;

    In our case, we want the following
    • We want the condition to be "bullish or bearish"
    • We want to use the colors Green and Red

    For the first bullet, "Bullish" can mean "prices are rising", and "Bearish" can mean "Prices are falling", so we can use these conditions as is. I am providing links to the Help Guide documentation for both.






    We can decide if we are neither rising nor falling, to just leave the color alone, so that it will remain red or green. This gives us the following code block :


    Code:
     [FONT=Courier New]    // Color the plot based on plot value conditions[/FONT][FONT=Courier New]
         if (Rising(MyMACD))[/FONT]
    [FONT=Courier New]        curColor = Color.Green;[/FONT]
    [FONT=Courier New]     else if (Falling(Upper))[/FONT][FONT=Courier New]
    [/FONT]
    [FONT=Courier New]        curColor = Color.Red;[/FONT]
    [FONT=Courier New]PlotColors[0][0] = curColor;[/FONT]
    You will need to add the curcolor property with a default value and the MyMACD plot. I am attaching an indicator with this OnBarUpdate block implemented. Please let us know if there is any other way we can help.
    Attached Files
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    82 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    43 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X