Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting the BlockVolume Indicator to run accurately, is it possible?

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

    Getting the BlockVolume Indicator to run accurately, is it possible?

    Good day,

    since the BlockVolume indicator seems handy to get a greater insight into volume movement, I thought about implementing it into some scripts and my chart setup. Though it turns out that it doesn't plot on TickReplay enabled charts, and some of my indicators require TickReplay enabled.
    Is there a way to have BlockVolume and Tick Replay Indicators at the same time?

    Secondly, (when not having TickReplaya enabled) the genuine BlockVolume Indicator, changes it's values after reloading the chart and after each reload only shows values for the last 30 bars or so. I have some screenshots attached.
    The lowest indicator is a test scripts with the following key elements.:
    Code:
    private BlockVolume BlockVolIndicator1;
    
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    }
    else if (State == State.DataLoaded)
    {
    BlockVolValues = new Series<double>(this);
    BlockVolIndicator1 = BlockVolume(5, CountType.Volume);
    }
    }
    
    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 0){
    if (CurrentBar != activeBar){
    BlockVolValues[1] = BlockVolIndicator1[1];
    BlockVolumeBars[1] = BlockVolValues[1];
    activeBar = CurrentBar;
    }
    BlockVolumeBars[0] = BlockVolValues[0];
    }
    }
    // ----Alternatively:  ----
    protected override void OnBarUpdate()
    {
    BlockVolumeBars[0] = BlockVolIndicator1[0];
    }
    With both versions the script doesn't always show the same values as the genuine BlockVolume Indicator, and the discrepancies aren't just some volume points, it misses entire candles. Additionally after each reload all indicators show different values as before (and as said at the beginning only the last 30 bars or so).

    My question is, is that just the way it is and the BlockVolume Indicator is designed that way or am I doing something wrong? If so, I would love to know how to solve all the described issues.

    Greetings,
    Sebastian
    Attached Files

    #2
    Hello seykool,

    Thanks for your post.

    I am not having an issue adding BlockVolume to a Tick Replay chart as I am able to see the historical plots the same with Tick Replay on and off.

    BlockVolume uses a multi time frame approach where it adds a single tick data series for volume analysis. Tick Replay is not required for this indicator, but we should note that discrepancies can be seen with historical data when we use a multi time frame approach and a tick based bar. The discrepancies result from ticks that have the same timestamp. When bar data is unrolled in OnBarUpdate, it is done chronologically, and if there are ticks with the same timestamp, these may not get unrolled in the same order they were received.

    These discrepancies can be seen with Multi Time Frame indicators that add a single tick data series, and the discrepancies are seen with tick based bars in historical data only. The discrepancies would not be seen with realtime data or with time based bars. It only affects historical tick based bars. Large sized tick based bars may hide the discrepancies while smaller tick based bars will more likely show the discrepancies.

    A thread where we have discussed this in regards to Order Flow Cumulative Delta (which takes a similar approach) can be found below.

    Hi, this is an additional post to my earlier post https://ninjatrader.com/support/forum/node/1121004 I plotted the Cumulative Delta indicator on a 1 Range ES chart My settings for this indicator are: 1. Delta type = BidAsk 2. Period = Bar I let the indicator run for a while and then pressed F5 to refresh. To my shock, the


    Please note that with Tick Replay charts, you can consider adding a non Tick Replay data series to the chart, and have both data series plot in the same panel. Your Tick Replay indicators can be applied to the Tick Replay data series, and other indicators that do not require Tick Replay can be applied to the normal data series. This will improve loading times since less NinjaScripts will process historical data OnEachTick/OnPriceChange as would be done with a Tick Replay data series.

    We look forward to assisting.

    Comment


      #3
      Hello Jim,

      thank you for the explanation and the other thread, it's quite useful. Adding a second data series for non tick replay indicators etc. is a really great hint! It indeed saves processing time.

      After I opened a new chart the indicators finally works with and without TickReplay (I've tried it literally for days and hours on several charts before, I don't know what it was).
      Okay, I understand where the discrepancies come from. You said discrepancies appear only on tick based charts and in the other thread you said that's also a range chart.
      While it now works as it should on range charts, on a tick chart however, it only works sometimes, every fifth reload or so mostly it doesn't. I can't really nail it down to a specific setting. Though it doesn't load historical data on the tick chart only. Why is this?
      Another thing I have noticed with tick charts is that indicators which call the BlockVolume method only work when their logic is in BarsInProgress == 0 is true and that these indicators in response calculate the first volume bar wrong after reloading, on tick charts ( not on range charts,which are like you said also tick based). Could you advise me what this is? I made yet another screenshot.

      Regards, Sebastian
      Attached Files

      Comment


        #4
        Hello seykool,

        I may need some steps to encounter the same behavior you are witnessing with vanilla tick charts and data not loading. Could you give me some steps and screenshots showing what is unexpected? Please be explicit as possible, and please make sure you have updated to the latest version of the platform. Release 23 just came out yesterday.

        Download - https://ninjatrader.com/PlatformDirect

        If you can draw on the image using MS Paint or another image editor it can help to point things out. It sounds like you are reporting symptoms where data is having trouble loading and I would like to reproduce that behavior to either comment or report the matter.

        As for the indicator not being able to be referenced properly when hosted, please keep in mind that this indicator is taking a Multi Time Frame approach similar to Order Flow Cumulative Delta. I suggest performing the same type of code to use BlockVolume. I've attached an example. Plots are synchronized with the primary data series so this where it is best practice to reference plot values.

        With the example, you can set it to calculate on price change and you can add another BlockVolume to the chart with the same settings. We can see that the updates are synchronized and the prints match what we see in the developing plot value for BlockVolume.

        OFCD NinjaScript access - https://ninjatrader.com/support/help...ive_delta2.htm

        I look forward to assisting.
        Attached Files

        Comment


          #5
          Good morning Jim,

          alright, I just updated it. Thanks for the 'how to host an indicator that is based on another data series correctly'! That was what I was searching for. Where would the all the other indicator logic go? If I put it under if (BarsInProgress == 0) and the the blockvolume part as with the cumulative delta indicator approach, it calculates everything except the blockvolume twice.
          Nonetheless, the indicator still isn't able to reference the data properly in the cases where the not-loading-blockvolume appears, also with proper hosting.
          It occurs very infrequently. Today it was at first only when a chart had not been from the beginning on a tick chart (for e.g. opening a range chart, adding the indicators, and then switching to tick bars). After avoiding doing it, it worked for a while properly and then it continued to only draw the historical 30 bars, also when opening a completely fresh chart. This happens with all blockvolume values from all indicators that use it, also the genuine BlockVolume Indicator. I also noticed that sometimes on realtime data, there comes a tremedously big spike like 10 times higher than on all the previous bars, but not on all open blockvolume indicators. When I refresh the spikes are gone. Might be it were two ticks with simultaneous timestamp or some indicators didn't get the data or it wasn't a simultaneous timestamp and some got wrong data.

          As I said, it happens sometimes with these settings, sometimes with those settings and rarely with the same. The general approach would be to:
          1) open NT
          2) New &gt; Chart &gt; GC &gt; 4Range / 100Tick
          3) add the BlockVolume Indicator and the indicator I attached



          Regards,
          Sebastian
          Attached Files
          Last edited by seykool; 11-18-2020, 07:16 AM. Reason: I updated the post because it continued not loading the data correctly

          Comment


            #6
            Hello Sebastian,

            The indicator should be refenced in BarsInProgress 0 if it is synchronized to the primary data series.

            If you add a secondary data series and synchronized the indicator to that data series instead, the indicator should be referenced on that added data series' BarsInProgress index.

            Within the hosting script, we should update the indicator values on the BarsInProgress index of the single tick data series. This done in a BarsInProgress == 1 check in the example I shared.

            When I have tested adding BlockVolume to a Range chart and then switching to to a Tick Chart, BlockVolume is still showing values. This is testing on both Tick Replay data series and non. You may want to test with a low volume amount for BlockVolume since there may by blocks that are found in a range bar that fluctuates that wouldn't be found in a standard tick bar. Please provide specific steps that I can take to encounter any issues if you would like me to look into further.

            We look forward to assisting.

            Comment


              #7
              Hi Jim,

              regarding the BarsInProgress: that's what I thought. And although I coded the previously attached indicator this way it calculates the Buys and Sells twice and as a result plots the double amount compared to the same indicator logic without the BarsInProgress and without the blockvolume part.
              Like when OnBarUpdate consists only of this:
              Code:
              if (CurrentBar &lt; activeBar || CurrentBar &lt;= BarsRequiredToPlot)
              return;
              if (CurrentBar != activeBar)
              {
              if (buys &gt;= sells){
              Sells[1] = 0;
              Buys[1] = (buys - sells);
              }
              else if (buys &lt; sells){
              Sells[1] = (sells - buys);
              Buys[1] = 0;
              }
              buys = 0;
              sells = 0;
              activeBar = CurrentBar;
              }
              if (buys &gt;= sells){
              Sells[0] = 0;
              Buys[0] = (buys - sells);
              }
              else if (buys &lt; sells){
              Sells[0] = (sells - buys);
              Buys[0] = 0;
              }
              This however only happens in the live calculation. Once you refresh the chart, the values are again as they should, and the new values that come in are again doubled. Hope you know how to prevent it. I've attached the above described indicator version for reference.

              Regarding the BlockVolume itself: I wish I could give you a detailed description of when it occurs on my chart, but it seems to occur randomly. If I can finally isolate it, I'll write you again.

              Greetings,
              Sebastian
              Attached Files

              Comment


                #8
                Hello Sebastian,

                I don't see an issue with your code. If you are comparing against BuySellVolume, keep in mind that Buys contains Buys + Sells. This is to give a visual indicator on the indicator panel so both buys and sells can be seen on the bar slot.

                If you compare against this modified version of BuySellVolume, we see that your indicator is calculating the difference between buys and sells. This looks correct.
                Attached Files

                Comment


                  #9
                  Hello Jim,

                  I am comparing the "BlockVolume with Volume Test" Indicator with the "BlockVolume with Volume Test2". The ...Test Indicator is the same as the ...Test2 expect that it also incorporates the hosted blockvolume. So ...Test2 has the same logic just with all blockvolume parts removed. Thus they should both display the same values (expect for the blockvolume part obviously). Though, at least on my computer here, it doesn't.
                  As you can see on the screenshot (1) previously calculated values from historical data are identical for both indicators. The data that came recently in and was calculated live differs in a way that the ...Test Indicator, the one with the hosted blockvolume, displays twice the amount, as seen on screenshot (2). When I refresh the chart via f5 all historical values are again identical between both indicators, and on those bars that differed previously on screenshot (2) are now identical, screenshot (3). Nevertheless, new incoming data differs again (4).

                  Could you please confirm me that this discrepancy between these two indicators really doesn't occur on your computer? It would be the same as when adding a hosted blockvolume indicator to the buy sell volume script.
                  Attached Files
                  Last edited by seykool; 11-20-2020, 05:18 AM.

                  Comment


                    #10
                    Hello Sebastian,

                    Thanks for clarifying, I was just looking at BlockVolume-with-Volume-Test2.

                    If you add a data series we will get OnBarUpdate and OnMarketData iterations for these data series. Double volume would be counted in OnMarketData since it is being processed for the primary data series and the single tick data series. I would suggest adding a BarsInProgress check in OnMarketData so you are not double counting from the single tick data series.

                    I.E.

                    if(e.MarketDataType == MarketDataType.Last && BarsInProgress == 0)

                    With that added to BlockVolume-with-Volume-Test, results are what I would expect.

                    Please let us know if there is anything else we can do to help.


                    Comment


                      #11
                      Hi Jim,

                      ah that was why. With adding BarsInProgress also to the OnMarketData, it works now as expected, awesome! Thank you for the great help. Already thought my computer were broken, when you said it was working fine on yours.

                      Have a good weekend!

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      566 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      330 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      101 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      547 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      548 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X