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

How to cycle through volumetric bars with Ticks Per Level

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

    How to cycle through volumetric bars with Ticks Per Level

    I have a volumetric chart with 32 range and 4 ticks per level and I am trying to cycle through the bar 1 "level" at a time. In this case every 32 tick bar has 8 levels. When I try to cycle through the bar to print each level, I get 32 levels with each level repeated 4 times. Is there a special way I should be accessing the data intrabar? Here is an example of the code:

    for (int i = 0; i <= mBarSize; i++)
    {
    double mAskSide = Convert.ToDouble(barsType.Volumes[CurrentBar].GetAskVolumeForPrice(High[0] - (i * TickSize)));
    double mBidSide = Convert.ToDouble(barsType.Volumes[CurrentBar].GetBidVolumeForPrice(High[0] - (i * TickSize)));


    Print(mBidSide + " | " + mAskSide);
    } // end for​


    Here is what that prints out:

    Bid|Ask
    *** | ***
    0 | 1
    6 | 22
    6 | 22
    6 | 22
    6 | 22
    10 | 8
    10 | 8
    10 | 8
    10 | 8
    9 | 0
    9 | 0
    9 | 0
    9 | 0
    10 | 16
    10 | 16
    10 | 16
    10 | 16
    28 | 24
    28 | 24
    28 | 24
    28 | 24
    12 | 1
    12 | 1
    12 | 1
    12 | 1​


    So I get every level of the 32 tick bar instead of the 8 levels of the 4 tick grouped bar.
    Last edited by WonderMellon; 10-05-2023, 06:54 AM.

    #2
    Hello WonderMellon,

    Thank you for your post and welcome to the NinjaTrader forum community!

    I suspect that this behavior is due to the ticks per level being set to 4. Ticks per level aggregates price levels and merges the data together. If you would like to get ask volume and bid volume for each individual tick in a volumetric bar, you would need to have ticks per level set to 1 so the data is not aggregated and instead each price level delta result is calculated individually. For more details on Volumetric bars and their properties, please see the following help guide page:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Emily,
      How can I iterate through levels per bar instead of ticks per bar if I have levels per bar set to 4? I am not able to just count every 4th tick because the first and last is not guaranteed to have a full level.

      Comment


        #4
        Originally posted by WonderMellon View Post
        Emily,
        How can I iterate through levels per bar instead of ticks per bar if I have levels per bar set to 4? I am not able to just count every 4th tick because the first and last is not guaranteed to have a full level.
        What are you referring to as "levels per bar" and where do you have this set to 4? You mentioned that you have 32 range with 4 ticks per level, which creates 8 levels in the bar. In some cases, it is expected to have a volumetric remainder cell if a bar range is not evenly divisible by the ticks per level. This is mentioned on the help guide page I previously shared where it states:
        Please note that with a higher Ticks per level set, there could be Volumetric remainder cells as a result that are actually smaller than your set Ticks per level, as not all bar ranges could be evenly divisible by the Ticks per level value
        If you want all of the levels of the bar, you would need to change ticks per bar to 1. If you prefer to have ticks per bar set to 4 visually but would like your script to calculate based on ticks per level of 1, you could call AddVolumetric() in your script to add a volumetric series with ticks per level of 1 for the indicator calculations. This would also need a change of the script to use the added series rather than the primary series for calculations per the comment in the example here:


        For more details on working with multi-series scripts:


        Please let us know if we may be of further assistance.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Emily,
          I will try to be as clear as I can. Let's take a scenario where we have a 10 tick volumetric range bar. There are 10 ticks per bar. Then I setup a 10 tick volumetric range bar with 2 ticks per level. So now we have 10 ticks, but only 5 "levels."

          When I cycle through the 10 tick bar with 1 tick per level I get all 10 ticks and all levels have unique values for that tick. When I cycle through the 10 tick range bar with 2 ticks per level programmatically via GetAskVolumeForPrice it will cycle through all 10 ticks, but will duplicate the price per level. What I want is to get the aggregated data for the 5 grouped levels instead of the underlying 10 individual tick bars. Since the bar on the chart shows 5 levels, it would make sense that I can get the data for those 5 levels instead of the underlying 10 ticks. If I am to handle this logic myself in code, then I need to know the ticks per level setting on the bar itself. There does not seem to be a way for me to obtain the "ticks per level" setting from the bar data. Attached is a screen capture that shows the visual difference between the 2 bars.

          When I call the volume for price on the 10 range bar with 1 tick per level, I get the following result. I see all 10 ticks with the individual bid and ask for each individual tick.


          10 tick 1 tick per level
          Bid|Ask
          *** | ***
          12 | 7
          25 | 21
          38 | 28
          14 | 151
          45 | 34
          45 | 46
          50 | 54
          28 | 37
          52 | 28
          27 | 41



          When I call the volume for price on the 10 range bar with 2 ticks per level, I get the following result. I still see 10 ticks, but each bid and ask price is duplicated for each level.


          10 tick 2 ticks per level (notice 10 values but the data is duplicated per level)
          Bid|Ask
          *** | ***
          11 | 7
          10 | 13
          10 | 13
          13 | 22
          13 | 22
          101 | 97
          101 | 97
          175 | 142
          175 | 142
          66 | 33


          There has to be a way for me to cycle through the bid and ask to only get the combined 5 price level data once instead of the duplicated 10 tick. If, for some reason, I am supposed to build this logic myself, then I need to be able to code my indicator/strategy to know that the volumetric bar has a ticks per level setting other than 1.

          Right now I am completely stuck with duplicate results and no way of getting the data I need.​​
          Attached Files
          Last edited by WonderMellon; 10-08-2023, 05:42 PM.

          Comment


            #6
            Hello WonderMellon,

            Thank you for your reply.

            Upon further investigation, I was not able to find any property that allows access to the ticks per level value for Volumetric bars. I did find an existing feature request to get access to this information and I have added your vote to track additional interest. The internal tracking number for this feature request is SFT-4527. Please reference this internal tracking number when contacting Platform Support if you ever have questions regarding this feature request.

            When a feature request is implemented, you'll find a description of the new feature in the release notes:Thank you for using NinjaTrader.​
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Jonafare, 12-06-2012, 03:48 PM
            5 responses
            3,986 views
            0 likes
            Last Post rene69851  
            Started by Fitspressorest, Today, 01:38 PM
            0 responses
            2 views
            0 likes
            Last Post Fitspressorest  
            Started by Jonker, Today, 01:19 PM
            0 responses
            2 views
            0 likes
            Last Post Jonker
            by Jonker
             
            Started by futtrader, Today, 01:16 PM
            0 responses
            8 views
            0 likes
            Last Post futtrader  
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,792 views
            0 likes
            Last Post aligator  
            Working...
            X