Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OrderFlow VWAP BarsAgo Error

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

    OrderFlow VWAP BarsAgo Error

    hello,
    I try to use VWAP in my strategy.
    But I don´t know where is the mistake.
    when I run the strategy appears an error:
    Strategy 'myVWBSAEK': Error on calling 'OnBarUpdate' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    Attached Files

    #2
    Hello, thanks for writing in.

    You should run the code in the primary series only, and also make sure there are bars in both the primary and secondary series:

    Code:
            protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0)
                    return;
                if(CurrentBars[0] < 400 || CurrentBars[1] < 400)
                    return;​

    Comment


      #3
      solved, thanks

      Comment


        #4
        Another question:
        Is possible to calculate VWAP onBarClose and avoid to use a a secondary bars series using ticks.?

        Comment


          #5
          Hi, The only way to use the OrderFlow VWAP is to use it with a 1 tick series, unfortunately, this is the only way it can be used.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          83 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          143 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          83 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          256 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          334 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X