Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

For loop not working

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

  • bradleg
    replied
    Good Morning, Good Traders!!!

    Thanks for the testing. I will look to replicate this later today.

    Background:
    I have loaded 800 days of data, and I have created 360 minute bars with that data.

    I have calculate on close set to True.

    I am not getting an explicit error, so I may have to check the output window for that -- thanks for the suggestion.

    I am getting NO output on the chart. If I change the length to 4, then I get output to the screen, but 5 or higher -- NO output.

    Thanks for all of your assistance.

    Leave a comment:


  • sledge
    replied
    Originally posted by bradleg View Post
    Higher numbers don't wok.

    Time frame is 360 minute. There is no secondary timeframe.


    I have restarted NT twice over two days.


    Again thanks or he reply, I don't understand it...
    I had to load up 50 days of data in my data series to get your for loop to work on 360 minute time frame.

    If I did not, I would get this error in the output window:

    Error on calling 'OnBarUpdate' method for indicator 'HighTest' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

    To bring up the output window, in Control Center, Tools->Output Window.

    Leave a comment:


  • Radical
    replied
    Originally posted by sledge View Post
    Are there errors in the output window?.
    Like sledge said, this would be helpful to know.

    Leave a comment:


  • sledge
    replied
    Originally posted by bradleg View Post
    Higher numbers don't wok.

    Time frame is 360 minute. There is no secondary timeframe.


    I have restarted NT twice over two days.


    Again thanks or he reply, I don't understand it...
    360 minute bars are 360/60=5.83333 hours per bar.

    What is your session template? Is this a stock or future?

    Whats are your days loaded set to for the chart? if it is 1 or 2 you would have troubles..., even with currentbar check, you might start working on day 3...


    Are there errors in the output window?

    Ill try this in the morning...

    Leave a comment:


  • bradleg
    replied
    Higher numbers don't wok.

    Time frame is 360 minute. There is no secondary timeframe.


    I have restarted NT twice over two days.


    Again thanks or he reply, I don't understand it...

    Leave a comment:


  • sledge
    replied
    Originally posted by bradleg View Post
    Thanks for your reply.

    I checked with this code....

    If (CurrentBar < 10)
    return;


    This is why I am so confused, especially since I put in this code.
    Does a higher # work?

    What time frames are you working in? (primary and secondary).

    Have you restarted NT?

    Leave a comment:


  • bradleg
    replied
    Thanks for your reply.

    I checked with this code....

    If (CurrentBar < 10)
    return;


    This is why I am so confused, especially since I put in this code.

    Leave a comment:


  • Radical
    replied
    It's possible that you don't have enough bars loaded to access High[4], but what is the error you're getting?

    Leave a comment:


  • bradleg
    started a topic For loop not working

    For loop not working

    Hi Guys,

    I wrote the following "for" loop in an indicator and if I set the loop limit to 5, the indicator will not output anything. If I set the loop limit to 4 then it will work.

    limit = 5;
    dHigh = High[0];

    for (int i = 1; i<limit; i++)
    {
    if (High[i] > dHigh)
    dHigh = High[i];
    }

    Why won't this loop work? I can't see any reason why this won't work.

    Please advise....

Latest Posts

Collapse

Topics Statistics Last Post
Started by kinfxhk, 07-14-2026, 09:39 AM
0 responses
127 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 10:18 AM
0 responses
105 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 09:50 AM
0 responses
85 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 07:21 AM
0 responses
105 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-11-2026, 02:11 AM
0 responses
86 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Working...
X