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

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.
        BertrandNinjaTrader Customer Service

        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 Jon17, Today, 04:33 PM
                0 responses
                1 view
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                4 views
                0 likes
                Last Post Javierw.ok  
                Started by timmbbo, Today, 08:59 AM
                2 responses
                10 views
                0 likes
                Last Post bltdavid  
                Started by alifarahani, Today, 09:40 AM
                6 responses
                40 views
                0 likes
                Last Post alifarahani  
                Started by Waxavi, Today, 02:10 AM
                1 response
                19 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Working...
                X