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

Need Help With Color Coded MACD

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

    Need Help With Color Coded MACD

    I've downloaded the MACDUpDn indicator which plots a different color for upticks and downticks in the histogram. What I would like to do is the same thing for the MACD plot itself. Is there anyone that would care to help me? Thanks and Best Regards

    Max

    #2
    Originally posted by maxreturn View Post
    I've downloaded the MACDUpDn indicator which plots a different color for upticks and downticks in the histogram. What I would like to do is the same thing for the MACD plot itself. Is there anyone that would care to help me? Thanks and Best Regards

    Max

    Hi Max,

    Here we go: Place this piece of code after line 78.

    if (Rising(Value))
    {
    MacdRisingPlot.Set(1, Value[1]);
    MacdRisingPlot.Set(Value[0]);
    }
    else if (Falling(Value))
    {
    MacdFallingPlot.Set(1, Value[1]);
    MacdFallingPlot.Set(Value[0]);
    }
    else
    {
    MacdNeutralPlot.Set(1, Value[1]);
    MacdNeutralPlot.Set(Value[0]);
    }

    Then in line 40, i.e: Add(new Plot(Color.Green, "Macd"));
    Copy it twice below this one and change "Macd" with MacdRisingPlot, MacdFallingPlot,MacdNeutralPlot and also choose the colors you wish.

    Finally in the properties Section find:
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Default
    {
    get { return Values[0]; }
    }
    again copy it twice, replace "Default" as above with MacdRisingPlot, MacdFallingPlot,MacdNeutralPlotand and in Values increase by one: Values[0], Values[1],Values[2].
    Also, change the values that the other plots had ie Avg from [1] now [4],
    2->5, 3->6 .

    Cheers

    Comment


      #3
      Astra, thanks a bunch. I understand most of what you said but I'm a little confused about the last part. I understand copying the "default" twice and having MacdRisingPlot, MacdFalingPlot and MacdNeutralPlot but I'm confused about the values. If I understand you correctly you're saying to have values 0-2 for the new plots and then change all the other values correct? Also, I noticed that there are two lines of code "///Summary" before and after each piece of code in this section. Do I need to edit the code to include this before and after my new plots? Again, thanks for all your help!

      Best Regards
      Max

      Comment


        #4
        Originally posted by maxreturn View Post
        Astra, thanks a bunch. I understand most of what you said but I'm a little confused about the last part. I understand copying the "default" twice and having MacdRisingPlot, MacdFalingPlot and MacdNeutralPlot but I'm confused about the values. If I understand you correctly you're saying to have values 0-2 for the new plots and then change all the other values correct? Also, I noticed that there are two lines of code "///Summary" before and after each piece of code in this section. Do I need to edit the code to include this before and after my new plots? Again, thanks for all your help!

        Best Regards
        Max

        Max,

        Give me few minutes and I will make it ready for you. Maybe others (including myself!) will benefit as well.

        If in the meantime you like to have a go (I remember how it feels when
        I managed my first code in C#!), the idea is that you have to match the sequence the plots are placed under Initialize, in the properties section, starting from 0. So, the first plot under Initialize, in the properties section will be
        {
        get { return Values[0]; }
        }

        The second [1], and so on. Don't bother about the summaries, either live them or delete them.

        astra

        Comment


          #5
          Max,

          Here is your requested indicator. I left the Macd as transparent in case you need the value for a strategy. Also, I have added background color (if you don't need it you can remove this line of code).

          Have a nice day.
          Last edited by astra; 12-08-2009, 09:59 AM.

          Comment


            #6
            Originally posted by astra View Post
            Max,

            Here is your requested indicator. I left the Macd as transparent in case you need the value for a strategy. Also, I have added background color (if you don't need it you can remove this line of code).

            Have a nice day.
            What Can I say Astra. HUGH ROCK! Thank you so much. I will study the code and try to brush up so I can do more of this on my own. I am a professional trader. If there's anything I can ever to do help you please let me know. God Bless!

            Max

            Comment


              #7
              Astra, slight problem with MACD plot

              Hello Astra. I just did a visual inspection of the indicator and it appears there's a slight problem I believe is just limited to the MacdFallingPlot. For some reason in a number of cases even the the MACD plot clearly ticks down it stays th same color as MacdRisingPlot. I verified this by looking in the data window. Even though it ticks down both MacdRisingPlot and MacdFallingPlot show a value.

              Regards
              Max

              BTW...I love the background color.

              Comment


                #8
                Hi Max,
                I am happy to have been of help.
                Best wishes,
                astra

                Comment


                  #9
                  Originally posted by astra View Post
                  Hi Max,
                  I am happy to have been of help.
                  Best wishes,
                  astra
                  Hello Astra. I just did a visual inspection of the indicator and it appears there's a slight problem I believe is just limited to the MacdFallingPlot. For some reason in a number of cases even the the MACD plot clearly ticks down it stays th same color as MacdRisingPlot. I verified this by looking in the data window. Even though it ticks down both MacdRisingPlot and MacdFallingPlot show a value.

                  Regards
                  Max

                  BTW...I love the background color.

                  Comment


                    #10
                    Hi,
                    very nice ,thanks astra.

                    Comment


                      #11
                      Oopps! You have right. It is fixed now. Please download it again from my previous post. The reason was that when I changed the plot name from Value to MacdPlot I overlooked to make the changes in some places. Now it should plot correctly. Thanks for telling me.

                      Comment


                        #12
                        Originally posted by astra View Post
                        Oopps! You have right. It is fixed now. Please download it again from my previous post. The reason was that when I changed the plot name from Value to MacdPlot I overlooked to make the changes in some places. Now it should plot correctly. Thanks for telling me.
                        Astra, once again...thanks for your generous help. If there's anything I can ever do for you...just let me know. God Bless.

                        Regards
                        Max

                        Comment


                          #13
                          Astra, there are still problems

                          Hello Astra. I downloaded and imported the revised indi and there is still a problem on several datapoints where the MACD clearly ticks down but for some reason the color stays the same as when the MACD ticks up. Any ideas? Thanks for all your help.

                          Regards
                          Max

                          Comment


                            #14
                            Screen shot?

                            Mike

                            Comment


                              #15
                              Hi Max,
                              I 'll have a thorough look this time but I suspect that you refer to the joint points when MACD changes direction. This is a problem with the way that NinjaTrader draws the lines. Anyway, I'll come back to you soon.
                              astra

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X