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

Williams Acc Dist Indicator not plotting

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

    Williams Acc Dist Indicator not plotting

    I haven't programmed in a decade or so and never in C#. I've been working this code for a bit but can't seem to get it to plot. I'm sure it's something simple but it is eluding me at the moment. Maybe fresh experienced eyes can help.

    I will post to the indicators section once complete.

    Thanks!
    Attached Files

    #2
    buzzsaw, please change if (CurrentBar > 0) to if (CurrentBar > 1).

    Also, on the very first bar, you'll have to set AD to something. As of now, it is set to the previous value of AD (+ priceMove), which doesn't exist on the very first bar.

    Let me know if that doesn't do the trick.
    AustinNinjaTrader Customer Service

    Comment


      #3
      That didn't seem to work

      I must have caused another problem trying to do the first calculation. Here's what I'm attempting to do:

      1. After first bar closes AD = high - close (just the range of the bar)
      2. After the second bar closes it's previous AD + PriceMove
      3. On the 57th bar (period default) I want to calculate the ZLEMA of AD

      Do I understand bar numbering and bar counting wrong with the available commands?

      Latest attempt attached.
      Attached Files

      Comment


        #4
        buzzsaw, I think you have everything correct save one item: NinjaTrader starts counting bars at 0 and not at 1, like when you set AD. Try using just the range if the current bar is 0 and not 1. Are you seeing any errors in the logs (right-most tab of Control Center)?
        AustinNinjaTrader Customer Service

        Comment


          #5
          Nothing in the log, just connection things. Going from 1 to 0 in the set AD doesn't make it work either.

          I'm sure there's some little nuance in the logic but it's not obvious.

          Will keep looking at it and code references to make sure everything's getting initialized and used properly.

          It seems so simple but yet it's turning out to be a challenge.

          Comment


            #6
            Originally posted by buzzsaw View Post
            I must have caused another problem trying to do the first calculation. Here's what I'm attempting to do:

            1. After first bar closes AD = high - close (just the range of the bar)
            2. After the second bar closes it's previous AD + PriceMove
            3. On the 57th bar (period default) I want to calculate the ZLEMA of AD

            Do I understand bar numbering and bar counting wrong with the available commands?

            Latest attempt attached.
            This looks incorrect:
            Code:
            AD.Set((CurrentBar == 1 ? (Close[0] - Low[0]) : AD[1]) + priceMove);
            as AD[1] is not defined on bar0, but will be evaluated, as on bar0, CurrentBar != 1.

            IMHO , it is better to escape bar0, then process all others, instead of processing "if CurrentBar >1". The alternative is to move the statement into the block that starts "if (CurrentBar > 1) {...}" and change that condition to "if (CurrentBar >= 1).
            Last edited by koganam; 06-12-2011, 10:24 AM.

            Comment


              #7
              Not sure I understand what you mean to do.

              I've been through the sequence with current bar>0, >=0, >1, >=1 as well as in combinations with ADSet currentbar=0, 1 etc. yet nothing seems to work.

              I do need to set AD[0] to something before I can reference it on the calculation for AD on the close of the second bar. It is supposed to be close - low on completion of the the first bar.

              I attempted variations on what you asked but that doesn't seem to work either.

              Comment


                #8
                Originally posted by buzzsaw View Post
                Not sure I understand what you mean to do.

                I've been through the sequence with current bar>0, >=0, >1, >=1 as well as in combinations with ADSet currentbar=0, 1 etc. yet nothing seems to work.

                I do need to set AD[0] to something before I can reference it on the calculation for AD on the close of the second bar. It is supposed to be close - low on completion of the the first bar.

                I attempted variations on what you asked but that doesn't seem to work either.
                You have done this?
                Code:
                		if (CurrentBar >= 1)
                			{
                			// calculate true range high and low
                			trueRangeHigh = Math.Max(High[0], Close[1]);
                			trueRangeLow = Math.Min(Low[0], Close[1]);
                
                                        priceMove = 0;
                
                			// compare closing price to yesterdays
                			if(Close[0] > Close[1])
                				{
                				priceMove = Close[0] - trueRangeLow;
                				}	
                				else if(Close[0] < Close[1])
                				{
                				priceMove = Close[0] - trueRangeHigh;
                				}
                				else if(Close[0] == Close[1])
                				{
                				priceMove = 0d;
                 		           	}
                		AD.Set((CurrentBar == 1 ? (Close[0] - Low[0]) : AD[1]) + priceMove);
                			}
                Last edited by koganam; 06-12-2011, 10:28 AM.

                Comment


                  #9
                  Yes, I did that. Unless I disturbed something else along the way that didn't work.

                  Something still seems to be missing in the logic.

                  Comment


                    #10
                    Originally posted by buzzsaw View Post
                    Yes, I did that. Unless I disturbed something else along the way that didn't work.

                    Something still seems to be missing in the logic.
                    OK. I took another look, and realized that while your logic is correct, the indicator is in fact doing exactly as you asked.
                    • Why are you using DataSeries to hold your values? Any particular reason why you are not assigning them directly to a plot?
                    • Your plot properties are not defined.

                    Comment


                      #11
                      Originally posted by buzzsaw View Post
                      Yes, I did that. Unless I disturbed something else along the way that didn't work.

                      Something still seems to be missing in the logic.
                      Take a look at this.

                      See that I have remarked out your DataSeries, and defined the Plots' properties, so that the values can be assigned correctly to the plots?

                      If I had not defined the Plots properties, then your assignments to AD and ADMA should have been to Values[0] and Values[1] respectively.
                      Attached Files

                      Comment


                        #12
                        Yeah. THANK YOU.

                        Not sure why it works. I see what you did with commenting out the data series elements but unclear why the the region properties were added. Did that happen when you compiled or something you just have to know to add??

                        A thank you added to your growing tributes.

                        Comment


                          #13
                          Originally posted by buzzsaw View Post
                          Yeah. THANK YOU.

                          Not sure why it works. I see what you did with commenting out the data series elements but unclear why the the region properties were added. Did that happen when you compiled or something you just have to know to add??

                          A thank you added to your growing tributes.
                          I defined the Plots' properties in the "Properties" region that I added. I did state that you had not defined the Plots' properties.

                          Comment


                            #14
                            Hello,

                            Just joined here and need the Acc/Dis indicator, which I have found to be the best of all indicators, especially when combined with a few others.

                            Unfortunately NT doesn't offer this indicator as a standard and I am no programmer.

                            Where can I go now?

                            Thanks in advance for any help!

                            Regards,

                            locan.BBS

                            Comment


                              #15
                              Just select Search and type williams into the Search NinjaScript Files window and you'll get to the script file which you can import. There's a bunch of Bill Williams things in there but if you scroll down you'll see it.

                              Buzzsaw

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DayTradingDEMON, Today, 09:28 AM
                              2 responses
                              15 views
                              0 likes
                              Last Post DayTradingDEMON  
                              Started by Stanfillirenfro, Today, 07:23 AM
                              6 responses
                              23 views
                              0 likes
                              Last Post Stanfillirenfro  
                              Started by navyguy06, Today, 09:28 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              8 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by helpwanted, Today, 03:06 AM
                              2 responses
                              22 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Working...
                              X