Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Values[3][0] returning error

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

    Values[3][0] returning error

    Hi,

    I am working on an indicator that uses Values[x][x] variables.

    I added AddPlot for all of them, created the code, but at the Values[3][0] i get error.
    Part of my code :

    [CODE]

    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 500)
    return;​


    if ( x < y )
    Values[1][0] = 1;
    else Values[1][0] = 0;

    if ( x1 < y1 )
    Values[2][0] = 1;
    else Values[2][0] = 0;


    if ( x2 < y2 )
    Values[3][0] = 1;
    else Values[3][0] = 0;
    [CODE]

    I added prints to each section, and at the third section I get an error, regardless of how many bars i set to countedbars.
    I read the documentation about Values function, but am I still missing something?












    #2
    Hello gyilaoliver,

    How many AddPlot statements do you have in the script?

    The indexes that you are using, 1,2,3 would mean that you should have 4 total AddPlot statements. If you mean to have only 3 plots the indexes should instead be 0,1,2.

    Comment


      #3
      Oh I see, then this is what i am missing... I only have 3 AddPlot statements, now i get the error. Thank you very much for your help Jesse

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      128 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      74 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      116 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      110 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      89 views
      0 likes
      Last Post CarlTrading  
      Working...
      X