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

Specific Volume Bars of last X days

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

    Specific Volume Bars of last X days

    Hi, I wish to reference the 2:25pm-2:35pm 5-minute volume bars of each of the last 10 days to get the average of each 5 minute bar. Could you please advise how I would do that?

    For example:
    Day 1
    2:25-2:30pm = 300
    2:30-2:35pm = 500
    Day 2
    2:25-2:30pm = 500
    2:30-2:35pm = 400
    Day 3
    2:25-2:30pm = 700
    2:30-2:35pm = 800
    ...
    Day 10
    2:25-2:30pm = 100
    2:30-2:35pm = 200

    And then sum of the 10 days:
    Total 2:25-2:30pm = 3700
    Total 2:30-2:35pm = 5400

    Thanks.

    #2
    Hello desmond108,

    Thank you for your note.

    This could be done by writing an if statement checking if the time of the current bar is 2:30, and if so, save the bars volume to a dataseries. I wrote a sample for you which checks if the time is 225, and if so, saves that 5 minute bars volume to a data series and sets it to a plot. I do the same if the time is 2:30.

    You would then just have to sum the last 10 bars in those series to achieve what you’re looking for.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your response and the script Alan.
      I am sorry I mis-communicated my intent for the calculation.
      It was late in my timezone when I wrote it.
      I had meant to say that I do not know the exact time of the day I need the volume calculation as it is triggered by an arbitrary event so the time could be 2:25-2:35 or 3:15-3:20 or 4:35-4:45 or any arbitrary time.
      When an event occurs I then wish to caclulate the volume of the last 10 days of that same time and hence I need to look back in time.
      Your code is great but if I adopt that method I would have to create a time series for all the 5-min time slots of the day for the last 10 days to get a specific timezone calculation.
      Is there a better way for me to reference the volumes of arbitrary times looking back?
      Apologies for my lack of clarity in the first post.

      Much appreciated.

      Comment


        #4
        Hello desmond108,

        You might also accomplish what you're looking to do with a loop.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by stafe, 04-15-2024, 08:34 PM
        7 responses
        31 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by adeelshahzad, Today, 03:54 AM
        4 responses
        29 views
        0 likes
        Last Post adeelshahzad  
        Started by merzo, 06-25-2023, 02:19 AM
        10 responses
        823 views
        1 like
        Last Post NinjaTrader_ChristopherJ  
        Started by frankthearm, Today, 09:08 AM
        5 responses
        17 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        43 views
        0 likes
        Last Post jeronymite  
        Working...
        X