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

    #16
    laocoon, you're welcome - perhaps you could post the indicator you've put together so far, so I can take a look?
    BertrandNinjaTrader Customer Service

    Comment


      #17
      Bertrand, here you go.

      The MACDUpDown file is the original file downloaded from this forum.
      The MACDUpDownEuro file is the modified file where I included the relevant part of your MACDScale code, applied to the Euro FX (6E).

      There are 2 issues:
      1. The "diffArr" (Histogram) is declared as a private variable in the original MACDUpDown code and when I modify it to "public" the code works but then I get an error message regarding deserialisation when I restart Ninja.

      2. The Histogram of my version (MACDUpDownEuro) plots very different values than the original MACDUpDown file. The values for the macd line and the Avg line are correct.

      Thanks
      Attached Files

      Comment


        #18
        Laocoon,

        Normalizing is a mathematical process by which you compare the current data point to the range of data points over a particular period. When you normalize something you basically remove any associated unit or scaling. When that is done you can compare the current value of a data point to the range of data points.

        - You will not have the same values as the MACD indicator, b/c the units are removed.
        - The NormPeriod is the lookback period to compare the current value to the range of previous (how many previous values) back.
        You will only have positive values between 0 and 10.

        I hope this explains some things for you.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #19
          Originally posted by laocoon View Post
          Bertrand, here you go.

          The MACDUpDown file is the original file downloaded from this forum.
          The MACDUpDownEuro file is the modified file where I included the relevant part of your MACDScale code, applied to the Euro FX (6E).

          There are 2 issues:
          1. The "diffArr" (Histogram) is declared as a private variable in the original MACDUpDown code and when I modify it to "public" the code works but then I get an error message regarding deserialisation when I restart Ninja.

          2. The Histogram of my version (MACDUpDownEuro) plots very different values than the original MACDUpDown file. The values for the macd line and the Avg line are correct.

          Thanks
          Please check the file attached, minor change to subtract the correct multiplied values - looks ok to me then, have a good weekend.
          Attached Files
          BertrandNinjaTrader Customer Service

          Comment


            #20
            @Bertrand: It works perfectly, thanks a lot!

            @Mrlogik: Got it, will continue to play around with it. Thanks as well.

            Comment


              #21
              @Bertrand & mrlogik

              I've been using the latest version published in this forum of the MACDUpDown indicator for quite some time now and it works perfectly, but it still isn't perfect because I have to create a different version for every market I trade (and adapt the multipliers in the code accordingly). There MUST be a way to avoid that since it has been done with many indicators (I'm attaching a version of the Ergodic indicator where this is the case, ie it oscillates between +10 and -10 for every market it is applied to). This makes things so much easier both visually, and also in terms of (strategy) development

              I'd very much appreciate if you could point me in the right direction on how to achieve the same thing with the MACDUpDown indicator (I guess it would also benefit other members of this forum)

              Thanks a lot.

              PS: it is important that the original values of the standard Ninja MACD indicator (and thus of the MACDUpDown) AREN'T modified in the process, which was the case with the version submitted by mrlogik.
              Attached Files
              Last edited by laocoon; 09-20-2010, 07:03 AM.

              Comment


                #22
                laocoon, please don't post scripts as assemblies here on the forums. You would need to review what the Ergodic is using then as normalization, I know of some approaches to normalize in respect to volatility this offering absolute comparion options of values generated.
                BertrandNinjaTrader Customer Service

                Comment


                  #23
                  Bertrand,

                  Could I ask you to have a quick look at the code below, it is the Ergodic I posted yesterday, but this time not as an assembly. It is not clear to me which part of it is the "normalising" part. It would help me a lot if you could highlight it for me. I'm trying to understand the normalising process in order to be able to replicate it in the MACDUpDown indicator.

                  Thanks a lot.

                  (For space reasons, I'm only posting the relevant part of the code)

                  // Init user data series
                  closediff = new DataSeries(this);
                  absclosediff = new DataSeries(this);
                  wERG = new DataSeries(this);
                  wERGhist = new DataSeries(this);
                  wErgodic = new DataSeries(this);
                  this.BarsRequired = 1;

                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {

                  if (CurrentBar == 0)
                  {
                  Values[0].Reset();
                  Values[1].Reset();
                  Values[2].Reset();
                  Values[3].Reset();
                  Values[4].Reset();
                  closediff.Reset();
                  absclosediff.Reset();
                  wERG.Reset();
                  wERGhist.Reset();
                  wErgodic.Reset();


                  return ;
                  }
                  else
                  {
                  closediff.Set(Close[0]-Close[1]);
                  absclosediff.Set(Math.Abs(Close[0]-Close[1]));

                  wERG.Set(WMA(WMA(absclosediff,fast),slow)[0] == 0 ? 0 : 100 * WMA(WMA(closediff,fast),slow)[0] / WMA(WMA(absclosediff,fast),slow)[0]);


                  wErgodic.Set(EMA(wERG,SignalLen)[0]);
                  Values[2].Set(50*(wErgodic[0]-wErgodic[1]));


                  Values[3].Set(0);
                  Values[4].Set(0);

                  if (Math.Abs(Values[2][0] - Values[2][1])>0.1)
                  {
                  if (Values[2][0]>= Values[2][1])
                  {
                  Values[3].Set(Values[2][0]);

                  }
                  else
                  {
                  Values[4].Set(Values[2][0]);

                  }
                  }
                  else
                  {
                  Values[4].Set(Values[4][1]);
                  Values[3].Set(Values[3][1]);
                  }

                  if (CurrentBar > SignalLen+fast+slow+1)
                  {
                  Values[1].Set(wErgodic[0]);
                  if (wErgodic[0] < wErgodic[1]) Values[0].Set(wErgodic[0]);
                  }
                  else Values[1].Set(wErgodic[0]);
                  }

                  Comment


                    #24
                    laocoon, this is the normalization here - it's dividing the abs momentum value into the regular momentun -

                    closediff.Set(Close[0]-Close[1]);
                    absclosediff.Set(Math.Abs(Close[0]-Close[1]));
                    BertrandNinjaTrader Customer Service

                    Comment


                      #25
                      Thanks for highlighting it. After comparing the code of the Ergodic and the MACDUpDown indicator, I'm afraid I won't be able to normalise the MACDUpDown according to the Ergodic normalising principle. The codes are just too different and require development skills I don't have.

                      Just a question here: why aren't all standard Ninja indicators (like the MACD) normalised in the first place? I'm happy to take the necessary time to dive into NinjaScript and to learn the basics of the development process (which I did), but I'm a bit frustrated when I have to devote a lot of time and effort for something that I feel should have been done by the original indicator developers. Normalised indicators make life a lot easier for all users, not just for me, so I feel it would benefit everyone if they would come normalised from the start.

                      Thanks

                      Comment


                        #26
                        Thank you for the feedback - we provide the industry standard indicator implementations with our system ones, any custom normalizing logic needs to be applied afterwards then.

                        Have you looked into for example running an unbounded osc like the RSI on the MACD to provide the normalizing for you?
                        BertrandNinjaTrader Customer Service

                        Comment


                          #27
                          Thanks for your tip regarding the RSI. I haven't tried that yet because as I mentioned earlier in the thread I succeeded in normalising the output of the MACDUpDown. The only problem is that I have to adapt the multiplier for every market I trade, which means that I have many different versions of the MACDUpDown.

                          The only reason why this bothers me is because my custom strategy is calling the MACDUpDown and as every MACDUpDown has another name (MACDUpDownEuro, MACDUpDownNasdaq, etc) I have to create a new version of the strategy for every market, which is very inefficient.

                          If anyone feels generous and could help me solve this issue I'd very much appreciate it.

                          Comment


                            #28
                            For this issue I would just make the multiplier a user defined input parameter of your custom MACD - http://www.ninjatrader.com/support/f...ead.php?t=5782
                            BertrandNinjaTrader Customer Service

                            Comment


                              #29
                              Bertrand,

                              That was a very helpful tip, thanks a lot. I modified my code accordingly and it works. The last thing I'd like to ask you is this: how can I "tell" the indicator which market it is applied to? Let me explain what I mean:

                              The multiplier to normalise the MACD for the Euro is 10000
                              The multiplier to normalise the MACD for the Yen is 1000000

                              Now, if I apply the MACD on a chart of the Euro, I obviously want the user defined input parameter to be 10000, whereas if I apply it on a chart of the Yen, the parameter should be 1000000.

                              How can I code the following: if market = Euro, then use multiplier of 10000 etc.

                              Thanks again for your help, it is much appreciated.

                              Comment


                                #30
                                You're welcome, you can access the instrument on the chart with the Instrument class and then set the value as needed - http://www.ninjatrader-support.com/H...umentName.html
                                BertrandNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by lightsun47, Today, 03:51 PM
                                0 responses
                                5 views
                                0 likes
                                Last Post lightsun47  
                                Started by 00nevest, Today, 02:27 PM
                                1 response
                                9 views
                                0 likes
                                Last Post 00nevest  
                                Started by futtrader, 04-21-2024, 01:50 AM
                                4 responses
                                45 views
                                0 likes
                                Last Post futtrader  
                                Started by Option Whisperer, Today, 09:55 AM
                                1 response
                                14 views
                                0 likes
                                Last Post bltdavid  
                                Started by port119, Today, 02:43 PM
                                0 responses
                                9 views
                                0 likes
                                Last Post port119
                                by port119
                                 
                                Working...
                                X