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

Dataseries-BarsInProgress-Volumetric

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

    Dataseries-BarsInProgress-Volumetric

    Hello,

    I use more than one dataseries in my script.

    When I have in OnBarUpdate "if(State==State.Historical) return;" it works OK.
    But when I add 2 x volumetric with eg
    in configure AddVolumetric("MNQ 06-20", BarsPeriodType.Range, 3, VolumetricDeltaType.BidAsk, 1);
    and in onbarupdate
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[2].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
    if (barsType == null) return;
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType2 = BarsArray[4].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
    if (barsType2 == null) return;

    and use it in the code eg like
    "&&(barsType.Volumes[CurrentBar].GetAskVolumeForPrice(Highs[2][1])+barsType.Volumes[CurrentBar].GetAskVolumeForPrice(Highs[2][1]-1*TickSize)"

    I get in the log tab the error message:
    "Time Category Message
    08.05.2020 10:28:00 Default Strategy 'Tx17xNQv1xAvolx1x2r': Error on calling 'OnBarUpdate' method on bar 1223456: Index was outside the bounds of the array."

    What might be the reason for this log-message please?

    Thank you!
    Tony

    #2
    Hello tonynt,

    One problem in what you provided is that you are using "CurrentBar". That will be the current bar for the series which called OnBarUpdate not necessarily the volumetric series. You could try using CurrentBars[2] instead to see if that is the reason for the error.

    You are also using other indexes in this syntax so at this point it would be best to reduce what you have and find what specifically is throwing the error.

    Please let me know if I may be of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      it works, so this was the reason!

      Thank you!!!

      Tony

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by samish18, 04-17-2024, 08:57 AM
      17 responses
      64 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by rocketman7, Today, 02:12 AM
      2 responses
      16 views
      0 likes
      Last Post rocketman7  
      Started by briansaul, Today, 05:31 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by PaulMohn, Today, 03:49 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by frslvr, 04-11-2024, 07:26 AM
      6 responses
      106 views
      1 like
      Last Post NinjaTrader_BrandonH  
      Working...
      X