Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dr. Charles Schaap ADX Setting?

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

    Dr. Charles Schaap ADX Setting?

    How would I implement Dr. Charles Schaap ADX Settings as an indicator?

    I'm watching this video explaining the ADX indicator: https://www.youtube.com/watch?v=0LPagXSPxL0 Around 7:10, the speaker introduces the Dr. Charles Schaap ADX Setting over the classic ADX indicator. The settings on the classic ADX are:

    14 periods for the DMIs
    14 for the smoothing, for the ADX

    The settings for the Dr. Charles Schaap ADX are:

    13 periods for the DMIs
    8 for the smoothing, for the ADX

    So, when I go Indicators -> DM, I see that, in my parameters, I have the period setting. However, there appears to be no setting for the smoothing value.

    How to implement? Thanks.

    #2
    The ADX is the average directional index developed by J. Welles Wilder. Its calculation involves the following steps:

    (1) calculate positive directional movement DM+, negative directional movement DM- and true range TR for each bar
    (2) calculate an exponential average (smoothing constant 1/14) for DM+. DM- and TR
    (3) calculate the directional index DX from the exponential average
    (4) calculate an exponential average (smoothing constant 1/14) from the DX in order to obtain the ADX

    As you can see, for both the steps (2) and (4), exponential smoothing with an EMA(27) is used. The EMA(27) is identical to Wilder's smoothing with a period of 14, as Wilder calculates the smoothing constant in a different way.

    Now, I have understood you correctly, Dr. Schaap uses an EMA(25) for the DM and TR smoothing (step 2) and then an EMA(15) for the smoothing of the DX (step 4). You can go further than that. You can also use different moving averages to do the smoothing. Wilder just selected the EMA because it was easy to calculate by hand, as it uses a recursive formula.

    For the screenshot below, I have used a 2-pole Gauss filter with a period of 25 for the DM and TR and a period of 15 for the ADX. The ADXR period is also set to 25.
    Attached Files

    Comment


      #3
      You can replicate the Schaap ADX by editing the standard ADX that comes with NinjaTrader.

      (1) save it under a new name

      (2) change line 27 to
      Code:
      private int period = 13;
      (3) add a new line 28
      Code:
      private int adxPeriod = 8;
      (4) replace line 94 with
      Code:
      Value.Set(sum == 0 ? 50 : ((adxPeriod - 1) * Value[1] + 100 * diff / sum) / adxPeriod);
      (5) add the following code within the properties region
      Code:
      /// <summary>
      /// </summary>
      [Description("Numbers of bars used for calculations")]
      [GridCategory("Parameters")]
      public int ADXPeriod
      {
          get { return adxPeriod; }
          set { adxPeriod = Math.Max(1, value); }
      }
      (6) compile the indicator

      Comment


        #4
        How do you save the ADX under a new name? I can only save the original ADX. I don't want to change it before saving it because I will probably mess it up. Thanks.

        Comment


          #5
          Originally posted by BottomShark77 View Post
          How do you save the ADX under a new name? I can only save the original ADX. I don't want to change it before saving it because I will probably mess it up. Thanks.
          In the script, right click => 'Save As' => rename it as you wish.

          The inds that come with NT can't in fact be modified without renaming.

          Comment


            #6
            Thanks. I kind of knew that you couldn't modify NT indicators but wasn't quite sure. Now if I can just figure out why I am having a problem with line 239.

            Comment


              #7
              Originally posted by BottomShark77 View Post
              Thanks. I kind of knew that you couldn't modify NT indicators but wasn't quite sure. Now if I can just figure out why I am having a problem with line 239.
              I notice that line 239 is the very last line of the ADX and is at the end of the normally 'hidden' section 'NinjaScript generated code' that it's usually best to leave unmodified.

              What's the problem or the error message?

              My guess is you've got a problem with curly brackets: one too many/too few. You've probably deleted one you shouldn't. I've done this many times and it drives you mad until you manage to 'balance them up'!

              Comment


                #8
                Originally posted by arbuthnot View Post
                I notice that line 239 is the very last line of the ADX and is at the end of the normally 'hidden' section 'NinjaScript generated code' that it's usually best to leave unmodified.

                What's the problem or the error message?

                My guess is you've got a problem with curly brackets: one too many/too few. You've probably deleted one you shouldn't. I've done this many times and it drives you mad until you manage to 'balance them up'!
                I can't remember the error message but I do remember it was a problem with a curly bracket. So I deleted the indicator and started a new one. Now I have the indicator compiled and working but it isn't plotting anything on the chart.

                Comment


                  #9
                  Originally posted by BottomShark77 View Post
                  I can't remember the error message but I do remember it was a problem with a curly bracket. So I deleted the indicator and started a new one. Now I have the indicator compiled and working but it isn't plotting anything on the chart.
                  The most common reason why an ind doesn't plot (assuming the coding is right) is that enough bars aren't allowed for (to allow for calculations) before it's meant to start plotting. Have you included something like:

                  if (CurrentBar < Period)
                  return;


                  (IN ADX, there is a line: if (CurrentBar < Period)... but maybe you need more than this.)

                  Comment


                    #10
                    Originally posted by arbuthnot View Post
                    The most common reason why an ind doesn't plot (assuming the coding is right) is that enough bars aren't allowed for (to allow for calculations) before it's meant to start plotting. Have you included something like:

                    if (CurrentBar < Period)
                    return;


                    (IN ADX, there is a line: if (CurrentBar < Period)... but maybe you need more than this.)
                    I have "if (CurrentBar < Period)" in the code, but If I put in "return;" as you have typed then I get an error where a statement is expected on line 83 column 6. No code. Right now line 83 is a curly with a sguiggly line after it.

                    Comment


                      #11
                      Originally posted by BottomShark77 View Post
                      I have "if (CurrentBar < Period)" in the code, but If I put in "return;" as you have typed then I get an error where a statement is expected on line 83 column 6. No code. Right now line 83 is a curly with a sguiggly line after it.
                      All I can suggest - assuming if (CurrentBar < Period) is the problem, is to place the statement at the very beginning of OnBarUpdate.

                      Comment


                        #12
                        Okay, I have it working. Thanks for the help! Oops. I have only one input instead of the 2 I was looking for. Just the 13. The 8 disappeared. Wow. lol FOMC time.
                        Last edited by BottomShark77; 06-17-2015, 11:57 AM.

                        Comment


                          #13
                          Originally posted by Harry View Post
                          You can replicate the Schaap ADX by editing the standard ADX that comes with NinjaTrader.

                          (1) save it under a new name

                          (2) change line 27 to
                          Code:
                          private int period = 13;
                          (3) add a new line 28
                          Code:
                          private int adxPeriod = 8;
                          (4) replace line 94 with
                          Code:
                          Value.Set(sum == 0 ? 50 : ((adxPeriod - 1) * Value[1] + 100 * diff / sum) / adxPeriod);
                          (5) add the following code within the properties region
                          Code:
                          /// <summary>
                          /// </summary>
                          [Description("Numbers of bars used for calculations")]
                          [GridCategory("Parameters")]
                          public int ADXPeriod
                          {
                              get { return adxPeriod; }
                              set { adxPeriod = Math.Max(1, value); }
                          }
                          (6) compile the indicator
                          Do you have the coding alterations necessary for NT 8? I am in need of the same Dr. Schaap settings and I would like to use them in the latest version of NinjaTrader.

                          Also, how do you alter the locked default ADX indicator in NT8? It says to save a "custom copy" because you cannot change a system indictor. The save functions aren't choosable in a locked indicator...

                          Thanks in advance!
                          Last edited by ArmKnuckle; 11-28-2015, 09:59 PM.

                          Comment


                            #14
                            Originally posted by ArmKnuckle View Post
                            Do you have the coding alterations necessary for NT 8? I am in need of the same Dr. Schaap settings and I would like to use them in the latest version of NinjaTrader.

                            Thanks!
                            Not yet. NT8 is still Beta.

                            Comment


                              #15
                              I have a Schaap ADX version for NT8 ready. I will publish it in a few days, as I am still considering to add a feature. If you need the Schaap ADX right now, please send me a private message with your e-mail.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GwFutures1988, Today, 02:48 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by ScottWalsh, 04-16-2024, 04:29 PM
                              6 responses
                              32 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by frankthearm, Today, 09:08 AM
                              10 responses
                              36 views
                              0 likes
                              Last Post frankthearm  
                              Started by mmenigma, Today, 02:22 PM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by NRITV, Today, 01:15 PM
                              2 responses
                              10 views
                              0 likes
                              Last Post NRITV
                              by NRITV
                               
                              Working...
                              X