Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

For loop not working

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

    For loop not working

    Dear All,

    Why is this loop not printing the last 100 closes ?

    regards,
    leduc

    protectedoverridevoid OnBarUpdate()
    {

    // double dblIndicatorSig = AtrCross(20)[0];
    for (int x = 0; x>100; x++)
    {
    Print (Close[x]);

    }
    }

    #2
    I think your (x >100) should be (x < 100)

    Comment


      #3
      That was not it unfortunately.

      If I do that, I only get the closing price of the first bar. If I change the 100 into 1, I get all the closes for all the bars loaded...

      Any deas anyone?
      leduc

      Comment


        #4
        leduc,

        you're probably having an issue because you're passing the amount of data loaded on the chart. Check the LOG tab; I bet you'll see an error.

        you want to do something like this

        Code:
        if(CurrentBar < 100)
            return;
        
        for(int i = 0 ; i < 100 ; i++)
            Print(Close[i].ToString());
        Also don't forget, this will give you 100 prints every bar, after the first 100 bars that is.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          Hi mrlogic,
          With that code it works now yes

          Thanks for the help,
          leduc

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          6 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Started by alifarahani, Today, 09:40 AM
          6 responses
          41 views
          0 likes
          Last Post alifarahani  
          Working...
          X