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

Normalising the Output of the MACD

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

    Normalising the Output of the MACD

    Hello

    I'd like to get a comparable scale for the same standard MACD study when applied to different markets.

    Example:
    For the DAX, the MACD scale goes from -5 to +5 (a good scaling in my opinion)
    For the Euro FX (6E), the MACD scale goes from -0.0005 to +0.0005 (much too small).

    This is pretty annoying because it makes it much more difficult to compare the MACD levels visually and is a pain when developing an automated strategy that uses the same MACD parameters to trade various markets.

    There's an easy workaround to fix this issue but I don't understand the code of the MACD well enough to do it myself. Basically, the solution would be to create a custom MACD indicator for every traded market and to multiply the output values of the MACD parameters (MACD Line, Avg Line and Histogram) by 10, 100, 1000 etc. according to the granularity of the underlying market.

    Example: if the output value of the MACD Line for the Euro FX (6E) is 0.00005, it would need to be multiplied by a factor of 100000 to get a more "readable" value like 5 etc.

    I'd really appreciate if someone could point me in the right direction on how to do that.

    Thanks a lot.

    #2
    Hi laocoon,

    You can edit the default MACD indicator at "Tools>Edit NS>Indicator" and save it as a new name. Then edit with your normalizing calculations.

    Something like....
    Code:
    Value.Set(macd * multiplier);
    TimNinjaTrader Customer Service

    Comment


      #3
      Hi Tim

      Thanks for your advice.
      This works perfectly with the MACD value, but I'm struggling to replicate it with the Avg (macdAvg) and with the Histogram.

      I tried Value.Set(macdAvg*multiplier) but it doesn't work. What am I missing?

      Thanks

      Comment


        #4
        laocoon, try for example this -


        Value.Set(macd * multiplier);
        Avg.Set(macdAvg * multiplier);
        Diff.Set((macd - macdAvg) * multiplier);
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand

          That's exactly what I figured out in the meantime, but I tried it and it doesn't work. I used a multiplier of 10000 for all three values (for the Euro FX, symbol "6E") but the indicator doesn't plot anything, it is totally blank. What's strange is that when I only use the multiplier for the macd variable, it works perfectly. It seems that adding the two other variables creates confusion.

          Thanks
          Last edited by laocoon; 05-31-2010, 10:44 AM.

          Comment


            #6
            laocoon, thanks for reporting back, looks like you've run into a bug in NT7 - we'll look into and let you know.

            Thanks for the support.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thanks Bertrand, looking forward to hearing back from you.

              Comment


                #8
                laocoon, checked into - just calculated values 'blowing up on you' as you multiplied them in the code - this can be resolved with using this attached indicator - works well on my end, please check.

                Thanks
                Attached Files
                Last edited by NinjaTrader_Bertrand; 06-02-2010, 04:40 AM.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  laocoon,

                  Are you looking to normalize this indicator between 0 and 100, so you can compare other normalized indicators to one another regardless of their scale?
                  mrlogik
                  NinjaTrader Ecosystem Vendor - Purelogik Trading

                  Comment


                    #10
                    @Bertrand: thanks for that, will try it out and let you know how it goes

                    @Mrlogik: I'm looking to normalize the MACD between 0 and 10 (or 20), so I can compare the MACD value of the Euro FX (6E) to the MACD value of the DAX Futures (FDAX), for example. Right now the FDAX is overbought if it reaches 10, whereas the 6E is overbought when it reaches 0.0001, which makes it impossible to include a certain (fixed) MACD "threshold" in an automated strategy for multiple markets.

                    Comment


                      #11
                      You're welcome, please let me know - you could also just calc for example a Stoch / RSI on the MACD series data to arrive at a rangebound indicator, like for example the TrendCycle from Schaff...
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Hey laocoon,

                        This can be done. You can mathatemically normalize between any min / max you desire. I have this coded on my home computer and can post a normalized MACD later.
                        mrlogik
                        NinjaTrader Ecosystem Vendor - Purelogik Trading

                        Comment


                          #13
                          Hi Mrlogik

                          That would be great, thanks a lot.

                          Comment


                            #14
                            Hi laocoon,

                            Attached is the normalized MACD indicator between 0 and 10.

                            I have a Normalizer function included to describe the math / logic behind it.

                            I hope this is what you were looking for.

                            mrLogik
                            Attached Files
                            mrlogik
                            NinjaTrader Ecosystem Vendor - Purelogik Trading

                            Comment


                              #15
                              @Bertrand: The MACDScale file works great, thanks a lot for that. Could I ask you one last thing: I'm using the MacdUpDown indicator (posted on the File Sharing, Indicators section of this site) rather than the standard MACD. (The only difference being that the histogram is colored green/red if it rising/falling.) I tried to apply your MacdScale indicator to the MacdUpDown and it works great for the Macd line and the Avg line, but I'm getting very different results for the histogram. I tried to adapt the code to get the correct histogram values, but with no success so far. Could you point me in the right direction?

                              @Mrlogik: I installed your indicator and played around with it, but I still have a few questions:
                              -The Macd line and the Avg line don't have the same values as in the regular Macd indicator. Does this have something to do with the NormPeriod?
                              -How do you use the NormPeriod?
                              -The histogram is always positive (at least I didn't manage to plot negative values).

                              Sorry for all those questions but I really would like to better understand how your indicator works.

                              Thanks to both of you.
                              Last edited by laocoon; 06-04-2010, 10:08 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by yertle, Today, 08:38 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post yertle
                              by yertle
                               
                              Started by Mestor, 03-10-2023, 01:50 AM
                              15 responses
                              378 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by samish18, Yesterday, 08:57 AM
                              10 responses
                              27 views
                              0 likes
                              Last Post samish18  
                              Started by matty89, 03-02-2020, 08:31 AM
                              34 responses
                              3,039 views
                              1 like
                              Last Post NinjaTrader_BrandonH  
                              Started by kujista, Today, 05:44 AM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X