Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volume over time?

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

    Volume over time?

    I am a basic Csharp programmer, I am much better at understanding code than writing it, but i hve made strides in creating my own product.

    I think Ninjatrader will eventually be perfect for me but atm, i have 2 questions;

    1. I programmed the following for the:

    minimum of a stock's SMA (10dayvolume) and the SMA of its(50dayvolume). the code is as follows:

    Add(PeriodType.Day, 1);
    double avgVolume = Math.Min ((SMA(Volumes[1],10)[0]) , (SMA(Volumes[1],50)[0]));

    and I cant get it to print the volume number.


    Ive been trading for 12 years, and I've decided for the sake of saving msyelf the many heart attackes per year, I am going to use full automation for my risk, profit and strategy parameters. This is one that I will be using.

    I'm sure im doing missing something that is right in front of my nose, but any questions/answers or tips that would lead me to some progress would be awesome....

    Thanks in adavnce,

    Andrew

    #2
    Hello,

    Thanks for your note and welcome to the support forum!

    double avgVolume = Math.Min ((SMA(Volumes[1],10)[0]) , (SMA(Volumes[1],50)[0]));

    This would need to be called in OnBarUpdate(). Also can you post a bit more code your doing to print as well.

    I look forward to assisting you further.

    BrettNinjaTrader Product Management

    Comment


      #3
      absolutely here is the code, and thanks for the quick response:

      {

      CalculateOnBarClose = true;

      }


      protectedoverridevoid OnBarUpdate()


      {

      Add(PeriodType.Day, 1);
      double
      avgVolume = Math.Min ((SMA(Volumes[1],10)[0]) , (SMA(Volumes[1],50)[0]));


      }


      {

      Print ("Avg volume:" + avgVolume);

      }


      Apologies if i left out something critical, please advise and many thanks.




      Comment


        #4
        Thanks for posting.

        Add(PeriodType.Day, 1);


        This is in the wrong spot. needs to be in Initialize() instead of OnBarUpdate().

        If in OnBarUpdate() it will add the bars series each time you get a tick which I'm surprised you did not run into major issues doing that. Move this up to Initialize and then let me know if it still is not working.
        BrettNinjaTrader Product Management

        Comment


          #5
          Still getting numerous errors; any help appareciated but a good many f them are asking me to place a } or ) where there already is one.

          Comment


            #6
            hoping for a little advice so i can work this out over the weekend....i am using a strategy as opposed to an indicator and not doing any coding through the wizard, as there really doesnt seem to be any needed. Thanks for any help.

            Andrew

            Comment


              #7
              alabell, are there any errors in the log (right-most tab of Control Center)? What are the other errors you are receiving?
              AustinNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

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