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

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 trilliantrader, 04-18-2024, 08:16 AM
    4 responses
    18 views
    0 likes
    Last Post trilliantrader  
    Started by mgco4you, Today, 09:46 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by wzgy0920, Today, 09:53 PM
    0 responses
    9 views
    0 likes
    Last Post wzgy0920  
    Started by Rapine Heihei, Today, 08:19 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by Rapine Heihei, Today, 08:25 PM
    0 responses
    10 views
    0 likes
    Last Post Rapine Heihei  
    Working...
    X