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

average based on time not bars

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

    average based on time not bars

    Scenario: I want to collect bar volume counts for a time back (e.g.last 2 hours) not a number of bars back. The only way I can think it might work is to process the vol data series bars in a loop until I get a bar whose bar time is less than Time [0] - 2 hours. I can't just subtract the oldest bar and add the newest as there may not be a one for one correlation or if I am using range or volume bars or the time may include a very slow period where there is not a bar for every bar period or possibly multiple bars..

    Solution: Each new bar close I will need to loop thru the Vol data series from most recent bar until I reach a low time bar or bar 0 (right to left). I have it working fine left to right but after 2 hours I have to reset the counts and start over. I don't want an accumulation of 2 hours but a rolling 2 hours plot.

    Question: Just checking to make sure there isn't a better way. The logic is simple but it will be a bit of a pig. It was the only way I could see to get the correct desired result no matter the chart time frame.

    Hope this makes sense.
    Last edited by ct; 03-23-2013, 10:01 PM.

    #2
    Originally posted by ct View Post
    Scenario: I want to collect bar volume counts for a time back (e.g.last 2 hours) not a number of bars back. The only way I can think it might work is to process the vol data series bars in a loop until I get a bar whose bar time is less than Time [0] - 2 hours. I can't just subtract the oldest bar and add the newest as there may not be a one for one correlation or if I am using range or volume bars or the time may include a very slow period where there is not a bar for every bar period or possibly multiple bars..

    Solution: Each new bar close I will need to loop thru the Vol data series from most recent bar until I reach a low time bar or bar 0 (right to left). I have it working fine left to right but after 2 hours I have to reset the counts and start over. I don't want an accumulation of 2 hours but a rolling 2 hours plot.

    Question: Just checking to make sure there isn't a better way. The logic is simple but it will be a bit of a pig. It was the only way I could see to get the correct desired result no matter the chart time frame.

    Hope this makes sense.
    Take a look at my last post in this thread. It essentially describes how to go about what you want to do.

    ref: http://www.ninjatrader.com/support/f...ion#post290792

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by tkaboris, Today, 05:13 PM
    0 responses
    2 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,281 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    19 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Tim-c, Today, 02:10 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    5 views
    0 likes
    Last Post Taddypole  
    Working...
    X