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

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

    Macd

    Hi guys,

    I'd like to create the same MACD as the one Barchart.com uses, which is shown here
    Technical futures chart with latest price quote for Crude Oil WTI, with technical analysis, latest news, and opinions.


    I took the regular MACD source code, copied and created a custom indicator and changed the plot colors to transparent for everything other than the Average (which is the line I believe Barchart solely uses for their MACD). However, there is still another line which won't go away, even when every line on the plot is supposedly transparent other than the average. I can't figure out why it's doing this.

    Here is my code (I only included the part of the original MACD code by NT which I edited)

    protected override void Initialize()
    {
    Add(new Plot(Color.Transparent, "Macd"));
    Add(new Plot(Color.Red,"Avg"));
    Add(new Plot(new Pen(Color.Transparent, 2), PlotStyle.Bar, "Diff"));

    Add(new Line(Color.Transparent, 0, "Zero line"));

    fastEma = new DataSeries(this);
    slowEma = new DataSeries(this);
    }

    #2
    Nevermind, for some odd reason, it now works. Anyway, I do have another problem. I need it to autoscale over the price. I drag and drop it to the price so it is overlayed, however, it still doesn't scale to price when I change the y axis.

    Comment


      #3
      albazzaztariq,

      You will need to set the scale justification for the MACD to either Left of Overlay from the indicator settings.
      Cal H.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Cal View Post
        albazzaztariq,

        You will need to set the scale justification for the MACD to either Left of Overlay from the indicator settings.
        It still doesn't work. I ran the backtest, dragged it onto the price chart, and in Properties changed it to Overlay and also Left with no results. When I change the y axis, the MACD line stays the same.

        Comment


          #5
          Can you post a screenshot of what you are seeing and what you want it to do?
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Cal View Post
            Can you post a screenshot of what you are seeing and what you want it to do?
            Attached are what's happening in the Charts tab of the Backtest window. As you can see in the file I uploaded named "1", the y axis is normal. In "2", I skew the y axis to be narrower, so the price bars change size but the MACD line stays the same. The MACD line needs to go with the price bars. In the first post of this thread, I pasted a link to the indicator as I want it seen. Refer to the Barchart.com link.

            Thanks
            Attached Files

            Comment


              #7
              I have just added the DM indicator and I have the same problem. These indicators do not properly scale on the axes vertically even though they do horizontally. This is after I change the scale justification in properties for those indicators.

              Comment


                #8
                The first link you sent me does not allow a non member like myself to view the page.
                Which is why I asked for a screenshot on what you see.

                This is to be expected when you are trying to scale in two different plots and different values. The most accurate you are going to get this to match up is to have the MACD in its own panel.

                Another way to look at this is that each plot has its own auto scale that is figured and calculated in the chart.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Attached is how I want it shown. Also, is there a way I can add something to make it always automatically overlay a certain indicator onto the chart? I don't want a separate panel for any of the indicators I'm using.
                  Attached Files
                  Last edited by albazzaztariq; 02-22-2014, 02:45 PM.

                  Comment


                    #10
                    I'm not sure which line that is on the chart. I know that the picture says MACD Oscillator however, there is only a line and no indication what this line is in relation to the MACD.

                    If you are wanting to overlay, you will need to set the scale justification to overlay in the Indicator settings.
                    Once you have changed that value you can then right click in the settings and select 'Set Default for "indicator"...'
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Cal View Post
                      I'm not sure which line that is on the chart. I know that the picture says MACD Oscillator however, there is only a line and no indication what this line is in relation to the MACD.

                      If you are wanting to overlay, you will need to set the scale justification to overlay in the Indicator settings.
                      Once you have changed that value you can then right click in the settings and select 'Set Default for "indicator"...'
                      Yes, but how am I going to get it to automatically scale to the price? Right now I have no use for the MACD line there, it isn't sized in relation to the price.

                      Comment


                        #12
                        Let me explain exactly what it is I need to do. I need to recreate the fit the MACD Avg which BarChart uses over the chart. According to the picture I have attached, you can see that the zero line is based on the average price over 6 months. You take the high and add it to the low, divide by 2 and you get where the zero line is to be set on the chart. This I can do myself, but how can I superimpose this over the chart in NT and also make it correctly scale to the axes?

                        Comment


                          #13
                          albazzaztariq, it would either or, once you have selected the overlay scale there would be no scale relation to price - that's the idea of it, be able to overlay on a completely unrelated scale.

                          What you certainly could do, is select to use a new scale on the left and then adjust via fixed scaling (just drag the left scale) as you see fit for your purpose.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            After looking over everything, I can see we can do it without the overlay. We can just use the separate panel and use criteria which would be the same anyway to use as signals.

                            Thank you

                            Comment


                              #15
                              I take profit of this post about MACD to ask:

                              how may I change the NJ default indicator for MACD in order to have different colors in the displayed histograms when they are increasing or decreasing, as it happens in the attached chart ?
                              Thanks in advance
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rexsole, Today, 08:39 AM
                              1 response
                              6 views
                              0 likes
                              Last Post bltdavid  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              6 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by gbourque, Today, 06:39 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post gbourque  
                              Started by trilliantrader, Yesterday, 03:01 PM
                              3 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by Brevo, Today, 01:45 AM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X