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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      63 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      90 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      47 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      105 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      63 views
      0 likes
      Last Post PaulMohn  
      Working...
      X