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

Time of Day Average Volume

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

    Time of Day Average Volume

    I'm in the process of moving from eSignal/Tradestation to NinjaTrader and am new to C# programming. I've been able to convert most of my indicators without too much difficulty, this one has me stumped. I'd like to code an indicator which plots the average cumulative volume per time bar over a user defined lookback period.

    For example, on the opening bar of the day, the indicator would plot the average volume of the previous [x] opening bars. On the next bar, the indicator would plot the average cumulative volume of the first two bars of the day over the lookback period [x].

    A reference sample of code, or a link to where I might find information how to code this would be very much appreciated. Thanks in advance.

    #2
    I am not sure I completely follow.

    Lets say you have 3 days.

    Current day (day 3) bar 1 value = Day1 bar1 + Day2 bar 1 + day3 bar1 / 3

    then

    Current day bar 2 value = (Day 1 bar1 + Day 1 bar 2) + (Day 2 bar1 + Day 2 bar 2) + (Day 3 bar1 + Day 3 bar 2) / 3
    RayNinjaTrader Customer Service

    Comment


      #3
      Some clarification

      Ray - Sorry if I wasn't very clear - I'll be more explicit:

      I'd like to code an indicator which plots the median trading volume in the ES futures contract for every 15 minute period over the last month. In other words, each 15 minute bar would show the median trading volume of the last 20 or so days.

      This analysis technique is detailed more thoroughly in these two posts in Brett Steenbarger's TraderFeed blog:

      A while back I posted a volume-based tool for identifying opportunity in the stock market. At the request of a couple of readers, I am upda...


      In a recent post , I suggested that we can track the presence of large institutional traders by knowing how current volume compares to avera...


      I hope this clarifies what I am trying to code. Thanks again.

      Comment


        #4
        Thanks for clarification.

        I can provide guidance on how to accomplish this.

        Calculate the number of bars within a session. For example:

        7:30 AM to 2:15 PM session yields 25 - 15 minute bars.

        Therefore, if I wanted to calculate the average over the past two days:

        volumeAverage = Volume[0] + Volume[25] / 2

        Since you are calculating over a n periods, you would have to utilize a loop to skip through the bars to get the correct values.

        Keep in mind, you have to check to make sure there are enough bars in your chart.

        if (CurrentBar < period * 25)
        return;
        RayNinjaTrader Customer Service

        Comment


          #5
          Thanks Ray - that helps a lot.

          Does NinjaScript support the statistical function median? I was unable to find it mentioned in any of the documentation. If not, do you have any suggestions for work-around?

          Thanks!

          Comment


            #6
            No we do not support a function to calculate the mean. You would have to code your own at this time.
            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by TraderBCL, Today, 04:38 AM
            2 responses
            6 views
            0 likes
            Last Post TraderBCL  
            Started by martin70, 03-24-2023, 04:58 AM
            14 responses
            105 views
            0 likes
            Last Post martin70  
            Started by Radano, 06-10-2021, 01:40 AM
            19 responses
            606 views
            0 likes
            Last Post Radano
            by Radano
             
            Started by KenneGaray, Today, 03:48 AM
            0 responses
            4 views
            0 likes
            Last Post KenneGaray  
            Started by thanajo, 05-04-2021, 02:11 AM
            4 responses
            471 views
            0 likes
            Last Post tradingnasdaqprueba  
            Working...
            X