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

Recommended data table usage in NT8 for capturing volumetric bar data?

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

    Recommended data table usage in NT8 for capturing volumetric bar data?

    Hi there!

    I'm wondering if the fine folks at Ninjatrader 8 have a recommended way of storing volumetric data into a table for future reference.

    Here's what I'm trying to do:
    Every volumetric bar usually has a maximum bid and ask on every bar. It's usually referenced like this via the NT8 guide example:
    Code:
    Print("Maximum Ask: " + barsType.Volumes[CurrentBar].GetMaximumVolume(true, out price) + " at price: " + price);
    Print("Maximum Bid: " + barsType.Volumes[CurrentBar].GetMaximumVolume(false, out price) + " at price: " + price);
    I'm looking to track when different 20 tick bars have the same maximum ask and bid, so I can draw a temporary horizontal line that only exists for a certain amount of bars.

    My instinct was to reference DataTable, set up some columns and a primary key, and extract the data after 20 trades/ticks have been completed on a bar. Then, I can basically reference the prices in the table over a certain number of looking-back bars to get the plot I'm looking for.

    But, should I just set up a native NT8 bar collection to do this? I'm not sure what would be the most efficient way of going about it?

    Any guidance would be very much appreciated.
    Thanks in advance!

    #2
    Hello Spiderbird,

    A SortedDictionary would likely be best, however this would all be up to you.

    A few examples below may give some ideas.
    Hello everyone I am trying to get the bid ask volume inside the bar from the example the problem is that I need a method to get the bid and ask volume without tick replay. I am trying to create this indicator on my own - from the example of the developers But the result is without successfully Below is my code I ask for

    Hi, i'm trying to build my first strategy. I want to use the values of the BuySellVolume indicator, but it seems like the DataSeries from the indicator are empty. No trade entry happens with this strategy.... The code looks like this: namespace NinjaTrader.NinjaScript.Strategies { public class DeltaRatioKursDivergenz :
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea!

      A SortedDictionary would be fantastic if I only had a pairing of a key and value. In my case, I need a lot more columns to record bar data from my tick chart. Here's a draft of what the schema looks like:
      • Bar (to record the results of the bar)
      • MaxBid_Price (highest bid on the buy side (on the left))
      • MaxBid_Above (one cent above MaxBid_Price)
      • MaxBid_Below (one cent below MaxBid_Price)
      • MaxBid_Volume (highest bid volume of the tick bar)
      • MaxAskPrice (highest bid on the sell side (on the right))
      • MaxAsk_Above (one cent above MaxAsk_Price)
      • MaxAsk_Below (one cent below MaxAsk_Price)
      • MaxAskVolume (highest sell volume of the tick bar)
      • Level (measures the number of times the max has been hit)
      • Color (the color of the plotted line, based on the level)
      • Expiration (when the line should degrade/disappear - measured in bars
      I'm thinking a DataTable would work best for this, but let me know if you think otherwise.

      And thank you very much for answering my question!

      Comment


        #4
        Hello Spiderbird,

        One possibility might be values could be stored in a custom class, which is stored for each bar in a sorted dictionary.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,

          At first glance, that seems like an additional layer of abstraction to work within a sorted dictionary framework. It definitely is a possibility.
          You had provided a URL in a previous message as an example. Do you have one for creating custom classes that can pair with NT8 strategies?

          Usually if I have an example, I can run with it.
          Thanks again for responding earlier.

          Comment


            #6
            Hello Spiderbird,

            Custom classes starts to get into advanced C# and out of the scope of NinjaScript Support. This is still a good place for your inquiry, as the forum community may have further insight.

            I have one script (ReuseDxBrushesLoopDictionaryExample_NT8) that uses a custom class.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Excellent! I'll roll with those examples and explore custom classes once I get the base code working. Thank you very much Chelsea!

              Comment


                #8
                Hi Chelsea,

                One quick follow-up. If I wanted to call a DataTable into a NT8 strategy script, do I need to call the namespace first in declarations?

                I'm trying to invoke 'using System.Data' and it's not recognizing it or can't call it. Trying to create a DataSet or DataTable outright isn't working either.

                Any tips or help?

                Comment


                  #9
                  Hello Spiderbird,

                  Using a DataTable is an advanced C# concept and not fully supported by the Scripting Support team.

                  There can be limitations using advanced C# concepts, in NinjaScript, so your mileage may vary. As of now, we do not have any examples that can be used to navigate that path.

                  You may need to add a reference to whichever assembly provides this namespace.
                  Last edited by NinjaTrader_ChelseaB; 01-27-2022, 08:22 AM.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Chelsea!

                    After doing a quick search on system.data and NT8, I found this reference in the NT8 forums that details how to add it through the NT8 Editor (NinjaScript editor->Right click->References):

                    using System.Data - NinjaTrader Support Forum

                    I successfully loaded up system.data after that, and will explore DataTable and the previous references you provided.
                    Thanks again!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by mattbsea, Today, 05:44 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post mattbsea  
                    Started by RideMe, 04-07-2024, 04:54 PM
                    6 responses
                    31 views
                    0 likes
                    Last Post RideMe
                    by RideMe
                     
                    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,282 views
                    0 likes
                    Last Post Leafcutter  
                    Started by WHICKED, Today, 12:45 PM
                    2 responses
                    20 views
                    0 likes
                    Last Post WHICKED
                    by WHICKED
                     
                    Working...
                    X