Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volume rate per second not working

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

    Volume rate per second not working

    Why isn't this code charting anything? COBC = false

    Trying to get an average volume per second by adding a PeriodType.Second,1 and then
    using Volumes[1] / AvgPeriod (user defined). I tried putting the plot.set inside the If action shown as below and it still doesn't work.



    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.SkyBlue), PlotStyle.Line, "VolAvgRate"));
    Overlay = false;

    //add a one second period type bars object
    Add(PeriodType.Second,1);


    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    // Do not calculate if we don't have enough bars
    if (CurrentBar < AvgPeriod) return;

    // Calculate the volume per second(user defined Period) of the periodtype.second bars object

    double volrate = 0;

    if(BarsInProgress == 1)

    {
    volrate = Volumes[1][0] / AvgPeriod;
    VolAvgRate.Set(volrate);
    }

    hmm, just thought of something. Maybe it is because there is no volume data provided on a per second basis.

    #2
    I have made this test case even simpler:

    in the initialize section

    Add(PeriodType.Second,1);

    In the OnBarUpdate section

    VolAvgRate.Set(Volumes[1][0]);

    VolAvgRate is the indicator plot. I would expect that the indicator would plot the value of the Volume for the second bar object which is volume on a one second basis.

    What is up with this?

    Comment


      #3
      Problem solved, added BarsRequired and other necessary functions.

      Comment


        #4
        Glad to hear your could resolve gdavis74, thanks for updating us.

        Comment


          #5
          WHERE CAN we download a good VOLUME PER SECOND INDICATOR for Ninja trader?



          I would love to check one out and test out some theories!


          THANKS

          Comment


            #6
            Hello InTheMoment,

            If the VOL indicator is applied to a seconds based chart this should provide you with the type of output you're looking for.
            KyleNinjaTrader Customer Service

            Comment


              #7
              Hello Kyle,

              Thanks for the reply...
              But I wanted to put it on a Tick chart...

              So it would have to be a indicator that is programmed to constantly read the Volume per second on a tick by tick basis.

              It would have to compare the volume traded on that tick with the timestamp of the that tick and the previous one...

              That should be relatively easy to to program - but I don't have the programming skills for it.

              The math would be:
              Volume traded on current tick + Volume traded on last tick divided by ( tick time stamp of current - tick time stamp of past tick)

              Except that the time stamp thing has to be fixed. If one tick comes just a few milliseconds from the last then the result is reading volume per those milliseconds.

              So the rate would still be correct but it would have to be standardized for 1 second.

              Comment


                #8
                Hello InTheMoment,

                If you have limited time or programming capabilities, NinjaTrader Ecosystem is partnered with a number of consultants who could code this indicator at your direction. If you would like more information regarding consultants please let me know.
                KyleNinjaTrader Customer Service

                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