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

Coding the difference between %D and %K for Stochastic (KDJ Indicator)

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

    Coding the difference between %D and %K for Stochastic (KDJ Indicator)

    Hi All,

    I couldn't find a KDJ indicator for N8. The KDJ is similar to the stochastic but adds a 'J' line that measures the difference between the %D and %K points. As this is only a simple calculation, I'm assuming it shouldn't be to difficult to code (?).

    I don't have much coding experience but I though my best chance would be to copy the stochastic indicator and code a J line that plots the difference. Could anyone assist me on how I can write a few lines of code that will subtract the %D point from the %K point?

    Thank you in advance.

    #2
    Hello birmako12,
    Thanks for your post.

    This would certainly be possible. I copied the Stochastics indicator and then added the following to create a "J" Line.

    Code:
    protected override void Initialize()
    {
        Add(new Plot(Color.Black, "J"));
    }
    protected override void OnBarUpdate()
    {            
        Values[2][0] = K[0]-D[0];
    }
    I suggest adding these lines to the bottom of Initialize() and OnBarUpdate() to make sure things are happening as intended.

    Let me know if you have any questions.
    Last edited by NinjaTrader_JoshG; 12-03-2018, 11:34 AM.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your prompt assistance Josh. Works as expected. However, I cant seem to select the new J line from value plots when selecting the new indicator in the strategy builder. Is this because I havent defined J?

      Thank you again
      Last edited by birmako12; 12-04-2018, 06:06 AM.

      Comment


        #4
        birmako12,

        You are correct. To expose something to the Wizard you would need to add a public property for it. In this case, for "J".

        I went ahead and added the property for you and attached the script. Please take a moment to see what has changed.

        To Import
        1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
        2. From the Control Center window select the menu File> Utilities> Import NinjaScript
        3. Select the downloaded .zip file
        4. NinjaTrader will then confirm if the import has been successful.
        Let me know if you have any questions.
        Attached Files
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Ninjatrader_JoshG hope you have been doing well, especially since this post is quite old. I am currently using Nt 8 and am very interested in using the Kdj your file is the only one I am able to find it seems but when i try to use it, of course it is out of date. Any way you could hook a brother up with an updated version?
          Best regards
          Montana

          Comment


            #6
            I am also hoping for an updated version of KDJ that actually works with v8

            Comment


              #7
              Originally posted by MontanaBalysky View Post
              Ninjatrader_JoshG hope you have been doing well, especially since this post is quite old. I am currently using Nt 8 and am very interested in using the Kdj your file is the only one I am able to find it seems but when i try to use it, of course it is out of date. Any way you could hook a brother up with an updated version?
              Best regards
              Montana
              Originally posted by technocharged View Post
              I am also hoping for an updated version of KDJ that actually works with v8
              I originally coded the NT7 version of this indicator in 2012 and posted on Futures.IO. Here is the NT8 version of the mahKDJ indicator:

              Enjoy!
              Attached Files

              Comment


                #8
                Hey Aligator, thank you very much my friend, very greatly appreciated.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,607 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                16 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X