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

How to modify the MACD indicator to paint the Bar color

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

    How to modify the MACD indicator to paint the Bar color

    Try to modify the MACD indicator and paint the macd bar color, when Diff > 0 paint to Green else Red.

    Are there any similar sample indicator scripts?

    #2
    Hello bibofeng,

    Thanks for your post.

    To create a copy of the MACD indicator to modify, open a New > NinjaScript Editor window, open the Indicators folder, and double-click on the MACD file. Right-click within the code of the MACD indicator, select 'Save as', name the copy of the file and click OK.

    After making a copy of the indicator, you could modify that copy to suit your overall goals.

    PlotBrushes[int PlotIndex][int barsAgo] would be used in a NinjaScript indicator to change the plot color to a specified color when a condition is true.

    We do not have a reference sample in the help guide that demonstrates this specifically. That said, the code to add to the copy of the MACD script might look something like this:

    Code:
    if (Diff[0] > 0)
        PlotBrushes[2][0] = Brushes.Green;
    else
        PlotBrushes[2][0] = Brushes.Red;​


    Note that the code above would be placed outside of the if-else condition used to assign plots a value.

    See this help guide page for more information about PlotBrushes and sample code: https://ninjatrader.com/support/help...lotbrushes.htm

    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your quick response. I got it!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      4 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      12 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      13 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,982 views
      3 likes
      Last Post jhudas88  
      Working...
      X