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

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

    MACD Histogram

    I've been trying to copy, rename (including the class name) and modify the MACD indicator that comes with Ninja to display the histogram only without success.

    What controls what is displayed by the indicator? In the stock MACD I commented out part of the following in hopes of displaying only the hist:

    //Add(new Plot(Color.Green, "Macd"));
    //Add(new Plot(Color.DarkViolet, "Avg"));
    Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "Diff"));

    The result was a blank panel 2.

    Thanks

    #2
    Hi gdargento,

    The reason you are getting a blank panel is because the Diff plot uses the Macd and Avg plots to calculate its value. This means you cannot simply comment out those two plots. What you need to do instead is change those plots into DataSeries instead. Using the DataSeries class allows you to maintain the plot values, but without the plotting graphics. You can review the exact details about them here: http://www.ninjatrader-support.com/H...taSeriesObject.

    So basically this is what you want to do:
    1) Add two DataSeries variables (Macd, Avg) to the Variables section.
    Code:
    private DataSeries     Macd;
    private DataSeries     Avg;
    2) In the Initialize() section you want to do
    Code:
    Macd = new DataSeries(this);
    Avg = new DataSeries(this);
    3) In the Initialize() section you want to delete/comment out those two plots you already did
    4) In the Properties section you want to delete the first two blocks of "public DataSeries" (delete Avg and Default).
    5) In the Properties section you want to modify the remaining DataSeries (Diff) to be placed into the proper index by replacing the 2 with a 0.
    Code:
    get { return Values[0]; }
    Hope that helps. If you have any more questions please feel free to ask.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      MACD Hist

      Much appreciated. Works!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pechtri, 06-22-2023, 02:31 AM
      9 responses
      122 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by frankthearm, 04-18-2024, 09:08 AM
      16 responses
      66 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by habeebft, Today, 01:18 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by benmarkal, Today, 12:52 PM
      2 responses
      15 views
      0 likes
      Last Post benmarkal  
      Started by f.saeidi, Today, 01:38 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X