Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

'barsAgo' needed to be between 0 and 4 but was 1

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

    'barsAgo' needed to be between 0 and 4 but was 1

    My code:

    1: if (!IsFirstTickOfBar)
    2: return;

    3: if (CurrentBars[0] < 3)
    4: return;

    5: Print(CurrentBars[0]);

    6: double fullRange = High[1] - Low[1];

    Why do I get the error in the subject ​at line #6? Calculate is set to OnPriceChange. I get the error when CurrentBars[0] was at 10

    TY!
    Last edited by cay7man; 12-25-2023, 10:56 PM.

    #2
    Hello cay7man,

    Thank you for your post.

    Are you adding any additional data series to your script? If so, I suggest also printing the value for BarsInProgress to see which series is calling OnBarUpdate():


    If this is a multi-series script, you could also specify the barsInProgressIndex for Highs and Lows (rather than using the High and Low values):



    If this is not a multi-series script or if you are still receiving the error even after checking the BarsInProgress, please provide a screenshot of the error message and a snippet of the code being used.
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
    ​Please let us know if we may be of further assistance.

    Comment


      #3
      TY! That resolved it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      590 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      342 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      555 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X