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

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.


    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 jclose, Today, 09:37 PM
            0 responses
            5 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,413 views
            0 likes
            Last Post Traderontheroad  
            Started by firefoxforum12, Today, 08:53 PM
            0 responses
            11 views
            0 likes
            Last Post firefoxforum12  
            Started by stafe, Today, 08:34 PM
            0 responses
            11 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by sastrades, 01-31-2024, 10:19 PM
            11 responses
            169 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X