• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

iterating Highs and lows

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

    iterating Highs and lows

    Hi,
    This seems like it should be so simple.
    This is in OnBarUpdate and Bars.Count is 1029.
    So why is it barfing when i == 13 with a null reference exception?

    if(CurrentBar == 0)
    {
    for (i = 0; i < Count; i++)
    Print(High[i].ToString());

    }

    Thanks ... Ed



    #2
    Originally posted by edstaffin View Post
    Hi,
    This seems like it should be so simple.
    This is in OnBarUpdate and Bars.Count is 1029.
    So why is it barfing when i == 13 with a null reference exception?

    if(CurrentBar == 0)
    {
    for (i = 0; i < Count; i++)
    Print(High[i].ToString());

    }

    Thanks ... Ed



    CurrentBar == 0 is the first bar on your chart. High[1] would be the high of the bar prior to the first bar. Obviously there is no such bar. High[i] would be the high of the bar i bars prior to the first bar. Obviously there is no such bar either.

    For (CurrentBar == 0) only High[0] is available.

    Comment


      #3
      Hello Ed,

      Thanks for your post and to follow up on Harry's comments your conditional statement if (CurrentBar == 0) is checking for the very first bar loaded, Bar 0.

      Bar1029 would be the bar on the right edge.

      Please let us know if you have further questions.
      Paul H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by morrnel, Today, 01:13 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by babouin77, Today, 12:41 PM
      6 responses
      14 views
      0 likes
      Last Post babouin77  
      Started by punkiy2111, Today, 12:17 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Tabor  
      Started by GLFX005, Today, 11:22 AM
      5 responses
      27 views
      0 likes
      Last Post GLFX005
      by GLFX005
       
      Started by mintxom, Today, 10:25 AM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Melissa  
      Working...
      X