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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          41 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          20 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          29 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          46 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          37 views
          0 likes
          Last Post CarlTrading  
          Working...
          X