Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error Onbarupdate from volumetric modification

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

    Error Onbarupdate from volumetric modification

    Hello,

    after modifying script strategy I have an error message
    18.02.2021 12:30:53 Default Strategy 'Tx102xBAxESv11': Error on calling 'OnBarUpdate' method on bar 5473: Index was outside the bounds of the array."
    and I cant find anything that might cause this. So I want to ask if this syntax here is not correct maybe with "BarsSeries" when adding more than one volumetric dataseries.


    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[0].BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
    if (barsType == null) return;

    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType2 = BarsArray[1].BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
    if (barsType2 == null) return;

    Thank you!
    Tony

    #2
    Hello Tony, thanks for your post.

    You must call AddVolumetric to add a secondary volumetric series:

    https://ninjatrader.com/support/help...volumetric.htm

    I discussed how to access the secondary series volumetric data here (your barsType2 = BarsArray[1] code is already correct and should work):



    Please let me know if this does not resolve your inquiry.

    Comment


      #3
      Hello,

      yes, or course I must call addvolumetric to add ....

      I tried to translate my thoughts and ask my question accurately. Can you please refer to my question.

      NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[0].BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
      if (barsType == null) return;

      OR

      NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[0].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
      if (barsType == null) return;

      Thank you!
      Tony


      Comment


        #4

        Hello tonynt, thanks for your reply.

        The proper way to cast the type is:

        NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType2 = BarsArray[2].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

        My test script works properly for this. Could you refer to this one to see what is different between my script and yours?

        Best regards,
        -ChrisL
        Attached Files

        Comment


          #5
          Hello,

          I try again with different question: when with "BarsSeries"
          NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[0].BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
          if (barsType == null) return;
          AND WHEN without "BarsSeries"
          injaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType2 = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
          if (barsType == null) return;

          Has this to do if primary dataseries or an added dataseries?

          Thank you!
          Tony

          Comment


            #6
            Hello tonynt, thanks for your reply.

            If you are asking why using BarsArray[0].BarsSeries.BarsType does not work vs using BarsArray[1].BarsType, its because BarsArray[0].BarsSeries is the Bars object of the primary data series. Any time you need to access multiple Bars objects in a multi time frame/instrument script use the BarsArray collection.

            Please let me know if I can assist any further.

            Comment


              #7
              Hello,

              no I do not ask why {0] does not work with [1].

              I asked several times in your language when to have the string "BarsSeries" in the syntax and when not.

              Thank you!
              Tony

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              71 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              143 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              76 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              47 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              51 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X