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 bmartz, 03-12-2024, 06:12 AM
    5 responses
    32 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by Aviram Y, Today, 05:29 AM
    4 responses
    13 views
    0 likes
    Last Post Aviram Y  
    Started by algospoke, 04-17-2024, 06:40 PM
    3 responses
    28 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by cls71, Today, 04:45 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X