Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Working with ADX

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

    Working with ADX

    I'm trying to build an indicator using ADX and am having trouble figuring out the value that is getting populated into my variable. The issue is ADX(14)[0] isn't giving me the same value as the value that is plotted when I call the ADX indicator that comes packaged with NT.

    I have:
    if (CurrentBar < 22) return;
    at the top of OnBarUpdate

    I have tried:
    double ADXvariable = 0; (in variables)

    and:
    ADXvariable = ADX(14)[0]; (in OnBarUpdate)

    I also tried creating a DataSeries to hold the values:

    private DataSeries ADXvalue; (variable)
    ADXvalue.Set(ADX(14)[0]); (OnBarUpdate)

    both of calculations return a value of 24.30 for IWM for today with CalculateOnBarClose = false (daily)

    But, when I add the packaged ADX indicator onto my chart, period 14, with CalculateOnBarClose = false, the indicator says the value is 31.14.

    Thoughts?




    #2
    Hi Grasul, from where do you run your custom study? From another chart or the Market Analyzer? Usually those differences stem from not having enough bars / data loaded (50 bars default for MA), so calculations haven't yet fully caught up.

    Comment


      #3
      Thank you for the reply.

      I am just in the first step of creating a new indicator. I can't copy and paste my code from here, but all the indicator does at the moment is if ADX < 20, it turns a flag to yes and starts drawing a dot, and then when ADX goes above 25 it swaps the flag and stops drawing the dots. This is all internal to a single indicator on a single time frame.

      All I want is an ADX value I can trust is correct to use in if statements for the flag swapping above.

      Should I set

      if (CurrentBar < 22) return;

      to a higher value maybe?

      Comment


        #4
        Thanks Grasul, I would ignore the current bars check for now and focus on how much days you give your indicator to load. It would be good to know from which chart it is exactly run to comment further. The CurrentBar check would be trimmed to the highest index back you try to access, as otherwise you would run into issues on the first bars of the chart, where a reference to the left simply would not exist then.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          It would be good to know from which chart it is exactly run to comment further.
          I don't understand the question; I'm sorry. I am writing a custom indicator. I declare a variable and then as the first action after the CurrentBar check I am setting the value of the variable:

          double ADXvariable =0; (in variables)
          ADXvariable = ADX(14)[0]; (in OnBarUpdate)

          When I DrawText the value of ADXvariable and compare it to the value of ADX when I just add the packaged ADX indicator to the chart, I have different values. (Both my custom indicator and the packaged ADX indicator have CalculateOnBarClose set to false because I am working with daily values in the evening.)

          Comment


            #6
            Thanks for clarifying, so you run this from the exact same chart the default NT ADX is on as well? I gave it a run on your IWM on Kinetick daily bars and cannot reproduce any issue, the simply test script is attached, all I'm doing is plotting your ADX value from the method call. Would this script also return a different output for the 2 ADX's for you?
            Attached Files

            Comment


              #7
              I won't be able to check what you sent until this evening Bertrand, but thanks for your help. I will compare what you sent to my code this evening.

              Comment


                #8
                Ok, sounds good, please let us know what your outcome in later testing is.

                Comment


                  #9
                  I can't seem to replicate the issue I was having last night either. Thank you very much for your help; the sample works perfectly. My apologies for the wild goose chase.

                  Comment


                    #10
                    No worries, thanks for providing the update.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    579 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    334 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    554 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    551 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X