Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate with oneachtick

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

    OnBarUpdate with oneachtick

    Hello,

    I made my indicators with COBCtrue and I know how to do with "if(....) return;" and all works ok.

    Now I run an indicator on each tick and I want to compare the current/developing volume with the volume of the bar before and plotting me backcolor to see easily when volume is higher.

    I have in onbarupdate
    if (BarsInProgress != 0) return;
    if (CurrentBars[0] < 2) return;
    if(VOL1[0] > VOL1[1] || VOL1[0] > VOL1[2]) BackBrush=Brushes.White;

    In log tab I get the error message
    15.12.2020 15:49:18 Default Indicator '': Error on calling 'OnBarUpdate' method on bar 2559: 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.

    What am I´m doing wrong here please?

    Thank you!
    Tony

    #2
    Hello Tony, thanks for your post.

    I made a test script that works fine with a single series:

    Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.


    If your script has a secondary series, make sure there is at least 2 bars on that series as well e.g. if (CurrentBars[0] < 2 || CurrentBars[1] < 2) return;

    Please let me know if I can assist any further.

    Comment


      #3
      Hello,

      thank you for your reply. I thought there is something different when running on eachtick. So the message seems to be from another indicator.

      Best regards
      Tony

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      577 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X