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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          265 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          169 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          171 views
          1 like
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          259 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          210 views
          0 likes
          Last Post CarlTrading  
          Working...
          X