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

Getting highest volume prices over a range of bars

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

    Getting highest volume prices over a range of bars

    I have an indicator that I want to plot the prices with the highest volume for the bars showing in the visible chart. I have populated a sorted dictionary object, and know how to get the top 5 levels, but I only need these values after the last bar on the far right is formed. Right now I am "grabbing" these values under the OnBarUpdate -- but it is performing the summation on every bar rather than on the whole collection of bars once.


    In NT 8, what is the best practice for "when"to grab these values? Since I am doing this on just the visible bars in the chart such that if I change the date range by dragging the x-axis right or left, should I get the values using the OnRender?

    Asked another way, maybe simpler, how do I 'get' the values for the whole collection just once rather than on every bar?
    Jim-Boulder
    NinjaTrader Ecosystem Vendor - Elephant Tracks

    #2
    Hello,

    Thank you for the post.

    If you are referring to just executing this code when you hit realtime, you could just use a state check such as if(State == State.Historical)return;

    Otherwise, If you are using the visible bar indexes that can change when you scroll, you could use either OnRender or OnBarUpdate depending on how frequent the update needed to be. So long as the OnBarUpdate logic can loop over the visible bars to do the calculation either would work.

    OnRender would be called many more times than OnBarUpdate so if you used OnRender you would also need to devise some logic to know when to call your calculation instead of calling it on each render. You could do this many ways such as using the visible bar indexes and checking if they had changed along with checking for a mouse up event.

    There is not really a specific best practice I could suggest here as I am unsure of the overall scope of the logic. It sounds like if the logic takes some time to process it would likely be best executed from OnBarUpdate. if you don't need to re-check the collection, potentially the results could be stored as a variable and referenced instead.

    I look forward to being of further assistance
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jessie,


      So if I excluded any data in realtime-is 'realtime' referring only to the active bar (and the tick data that may be streaming for it)? or does it refer to the data that has come into the 'chart' in realtime since you opened the chart?

      I need to explain one detail I have not provided....I am using "OnMarketData" to grab some additional details, so this indicator has to run on every tick -- thus further slowing down this indicator. I need it to sum up the volume, and only need the top 5 (as an example) values after considering all the visible bars.

      For this specific use case, I do need to recalculate it on every new tick but then the actual end result is the top 5 highest volume bars within the visible bars on the chart.

      I need it to sum on every tick/bar but just yield the final result once---for simplicity assume I am just 'printing' out the top 5 prices to the output window. I just need the final result after all the 'eligible' bars are considered.

      Right now, it is outputting on every tick--and I have to let it run and once it stops on the last bar---I manually take the last updated set of 5 prices...

      Just for clarity, if I am wanting to restrict the consideration to just the visible bars, do I have to perform this within the "OnRender" section or can the collection of visible bars be referenced anywhere , but specifically within the OnBarUpdate ?
      Last edited by Jim-Boulder; 04-09-2017, 02:39 PM.
      Jim-Boulder
      NinjaTrader Ecosystem Vendor - Elephant Tracks

      Comment


        #4
        Originally posted by Jim-Boulder View Post
        Thanks Jessie,


        So if I excluded any data in realtime-is 'realtime' referring only to the active bar (and the tick data that may be streaming for it)? or does it refer to the data that has come into the 'chart' in realtime since you opened the chart?

        I need to explain one detail I have not provided....I am using "OnMarketData" to grab some additional details, so this indicator has to run on every tick -- thus further slowing down this indicator. I need it to sum up the volume, and only need the top 5 (as an example) values after considering all the visible bars.

        For this specific use case, I do need to recalculate it on every new tick but then the actual end result is the top 5 highest volume bars within the visible bars on the chart.

        I need it to sum on every tick/bar but just yield the final result once---for simplicity assume I am just 'printing' out the top 5 prices to the output window. I just need the final result after all the 'eligible' bars are considered.

        Right now, it is outputting on every tick--and I have to let it run and once it stops on the last bar---I manually take the last updated set of 5 prices...

        Just for clarity, if I am wanting to restrict the consideration to just the visible bars, do I have to perform this within the "OnRender" section or can the collection of visible bars be referenced anywhere , but specifically within the OnBarUpdate ?
        Have you considered using IsFirstTickOfBar as your gate?

        ref: http://ninjatrader.com/support/helpG...ttickofbar.htm

        Comment


          #5
          Thanks for your idea! The more I think about this I realize the problem I am trying to solve is the speed at which the indicator runs - I realize now that it has to run for all bars, but I only need to plot it on the last bar (the most recent bar)...
          Jim-Boulder
          NinjaTrader Ecosystem Vendor - Elephant Tracks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by usazencort, Today, 01:16 AM
          0 responses
          1 view
          0 likes
          Last Post usazencort  
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          603 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          6 responses
          23 views
          0 likes
          Last Post xiinteractive  
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          22 views
          0 likes
          Last Post Pattontje  
          Started by flybuzz, 04-21-2024, 04:07 PM
          17 responses
          230 views
          0 likes
          Last Post TradingLoss  
          Working...
          X