• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Summing Volume of Two Instruments

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

    Summing Volume of Two Instruments

    I've attached a simple example indicator that sums the volume of multiple symbols on every tick. The purpose is to understand the concept of processing multiple symbols tick by tick. My indicator has no plots yet. I've just been testing by calling with an SMA Indicator using the public Series that I have exposed. I've tried it by itself and by calling it from a 1 period SMA and in either case I get this:
    Code:
    error on bar 0 that I am accessing an index with a value that is invalid since it is out of range
    .

    Can you offer an advice on what I am doing wrong as well as any general pointers about how I did this? I'd like to be able to call it from an SMA but I can't even get it to run on its' own. Thanks in advance. See attachment below:

    SumVolume.zip .

    #2
    Hello swooke,

    Thanks for your post.

    Dynamically adding data series following User Input is not supported. To proceed with any inquiries which require our support, please hardcode your added data series.

    Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.
    https://ninjatrader.com/support/help...dataseries.htm

    There is one reference which gives your error. Commenting this line prevents the error.

    Code:
    total[activeBar] += moneySpent;
    Since Series/Plots are synchronized to the primary data series, we recommend assigning plot/series values in OnBarUpdate. You could consider to follow an approach that is demonstrated in the BuySellPressure and BuySellVolume indicators where buy/sell volume is accumulated in OnMarketData and then assigned to a plot value in OnBarUpdate. You could do the same to accumulate volume * price for your added symbols and assign them to a plot in OnBarUpdate.

    As a final note, separate instruments will run on separate threads so there would not be a guarantee of the order of the ticks as they are streamed in from realtime data.

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Can you elaborate on what you mean by "not supported?" This is hard to understand. Spreads in trading are so common. I've been using a string input to collect symbol lists in NT for a long time. However, these have only been for my use until now. I've recently put a lot of time into polishing these up to begin offering them as a service. The symbol inputs only collect stock symbols and show an error if the user tries to enter anything else. These are just tools to plot pairs of stocks or baskets of stocks. Additionally, the indicator errors out if the user enters invalid stock symbols as well. Could NT refuse to be a partner of mine because of this? If they do, will you actually forbid me from selling them?

      Comment


        #4
        Hello swcooke,

        Although this works in most cases, we note in our documentation that this is not advised and attempting to do so is not guaranteed to function. A notable area where this will not work is with optimization backtests. You are welcome to use undocumented code and unsupported approaches with your NinjaScripts, but as with any unsupported approach you should be ready to "expect the unexpected."

        From a support perspective, any inquiries that involve dynamically adding the data series should be presented in a hard coded manner so the unsupported portion is ruled out.

        In regards to your first post, my suggestions to follow BuySellPressure/BuySellVolume for accumulating OnMarketData values in private variables and updating Series objects in OnBarUpdate will help move you forward.

        Let us know if you have any questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks Jim. About the BuySellVolume Indicator, can you point me to a resource that explains what
          Code:
          NinjaTrader.Custom.Resource.BuySellVolumeBuys
          and
          Code:
          NinjaTrader.Custom.Resource.BuySellVolumeSells
          is? I don't understand what that is doing in the AddPlot call.

          Comment


            #6
            Hello swcooke,

            These are strings fetched from NinjaTrader resource files and would be purposed for language translations where a different language will be pulled for the Plot name. The resource files are stored in the Documents\NinjaTrader 8\bin\Custom\ folder. I would not recommend editing these files to add your own international strings since they would be overwritten with updates to the NinjaTrader platform.

            Let us know if you have any additional questions.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by maltese, Today, 02:54 AM
            0 responses
            2 views
            0 likes
            Last Post maltese
            by maltese
             
            Started by morrnel, Yesterday, 04:18 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Marco  
            Started by jmahon, Today, 02:45 AM
            0 responses
            4 views
            0 likes
            Last Post jmahon
            by jmahon
             
            Started by brianshih, Today, 02:40 AM
            0 responses
            2 views
            0 likes
            Last Post brianshih  
            Started by franco12364, Yesterday, 02:29 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Marco  
            Working...
            X