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

Accumulation Distribution %

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

    Accumulation Distribution %

    I'm wanting to normalize my accumulation distribution indicator over a 10 day period but I'm having a tough time adding the tiny bit of code necessary. Hoping any of your experienced NinjaScript users can help me out.

    Currently ADL has the code:
    AD.Set((CurrentBar == 0 ? 0 : AD[1]) + (High[0] != Low[0] ? (((Close[0] - Low[0]) - (High[0] - Close[0])) / (High[0] - Low[0])) * Volume[0] : 0));

    I want to basically do this:
    AD.Set((CurrentBar == 0 ? 0 : AD[1]) + (High[0] != Low[0] ? (((Close[0] - Low[0]) - (High[0] - Close[0])) / (High[0] - Low[0])) * Volume[0] / 10-day sum of volume) : 0));

    bold is what I added. This indicator is talked about in John Bollinger's book in case any of you were curious.

    #2
    Originally posted by kzuschlag View Post
    I'm wanting to normalize my accumulation distribution indicator over a 10 day period but I'm having a tough time adding the tiny bit of code necessary. Hoping any of your experienced NinjaScript users can help me out.

    Currently ADL has the code:
    AD.Set((CurrentBar == 0 ? 0 : AD[1]) + (High[0] != Low[0] ? (((Close[0] - Low[0]) - (High[0] - Close[0])) / (High[0] - Low[0])) * Volume[0] : 0));

    I want to basically do this:
    AD.Set((CurrentBar == 0 ? 0 : AD[1]) + (High[0] != Low[0] ? (((Close[0] - Low[0]) - (High[0] - Close[0])) / (High[0] - Low[0])) * Volume[0] / 10-day sum of volume) : 0));

    bold is what I added. This indicator is talked about in John Bollinger's book in case any of you were curious.
    Code:
    double dblCumulative10DayVolume = SUM(Volume, 10)[0];
    Remember to check for "dblCumulative10DayVolume == 0", and handle it appropriately. I cannot tell you how many times that I have come to grief for not thinking about that one.

    Comment


      #3
      Originally posted by koganam View Post
      Code:
      double dblCumulative10DayVolume = SUM(Volume, 10)[0];
      Remember to check for "dblCumulative10DayVolume == 0", and handle it appropriately. I cannot tell you how many times that I have come to grief for not thinking about that one.
      Thanks for your quick reply. I'm still a little confused on what exactly you are saying. Would you mind basically writing the exact code I would need to enter? I'm a complete noob at NinjaScript as you can probably tell.

      Comment


        #4
        I want to basically do this:
        AD.Set((CurrentBar == 0 ? 0 : AD[1]) + (High[0] != Low[0] ? (((Close[0] - Low[0]) - (High[0] - Close[0])) / (High[0] - Low[0])) * Volume[0] / 10-day sum of volume) : 0));
        That pseudocode as written cannot compile because you have introduced an ambiguous closing bracket and so the expression does not make sense. Now that you have a idea of the formula, describe in English what the requirement is. Are you simply trying to divide the current value (as defined in the original file), by the 10-day sum of volume ?

        Comment


          #5
          After going back into the book the formula Bollinger lists is:
          10-day sum of [(close-open) / (high-low) * volume] / 10-day sum of volume.

          bolded is the part I think I forgot to mention. Thanks for your help koganam! I really appreciate it.

          Comment


            #6
            Originally posted by kzuschlag View Post
            After going back into the book the formula Bollinger lists is:
            10-day sum of [(close-open) / (high-low) * volume] / 10-day sum of volume.

            bolded is the part I think I forgot to mention. Thanks for your help koganam! I really appreciate it.
            The attached is a direct coding of what you specified. It is just a quick-and-dirty piece of coding with no error-checking. See if it does what you want, after which I will decide if I even need to put any kind of error-checking or limit filter on the plot.
            Attached Files

            Comment


              #7
              Originally posted by kzuschlag View Post
              After going back into the book the formula Bollinger lists is:
              10-day sum of [(close-open) / (high-low) * volume] / 10-day sum of volume.

              bolded is the part I think I forgot to mention. Thanks for your help koganam! I really appreciate it.
              kzuschlag, may we have some feedback on this one. Is the code what you expected? Have you had any funny problems running the indicator? Can we post it to the file sharing section?

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by usazencort, Today, 01:16 AM
              0 responses
              1 view
              0 likes
              Last Post usazencort  
              Started by kaywai, 09-01-2023, 08:44 PM
              5 responses
              603 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by xiinteractive, 04-09-2024, 08:08 AM
              6 responses
              22 views
              0 likes
              Last Post xiinteractive  
              Started by Pattontje, Yesterday, 02:10 PM
              2 responses
              21 views
              0 likes
              Last Post Pattontje  
              Started by flybuzz, 04-21-2024, 04:07 PM
              17 responses
              230 views
              0 likes
              Last Post TradingLoss  
              Working...
              X