Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsInProgress - Question

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

    BarsInProgress - Question

    I have this at the very beginning of OnBarUpdate(). It's a strategy.

    if (BarsInProgress != 0)
    {
    return;
    }

    //Only process if bar being updated is our 1st bar.
    if (BarsInProgress == 1)
    {
    Print("This should not be seen");
    }


    ------------------
    How come I can see the print statement above? I thought my first if() was going to return if true?

    What am I missing ??

    [UPDATE]
    Something was flaky. I just shutdown Ninja, re-opened, and it seems to be processing correctly. Weird.


    Thank you,


    r2kTrader
    Last edited by r2kTrader; 02-28-2009, 06:19 PM.

    #2
    Have you read this?



    OnBarUpdate is called for each indicator you have added to a strategy.

    Try this...

    // Process if OnBarUpdate is called for one indicator.
    if (BarsInProgress == 0)
    {
    Print("BarsInProgress == 0");
    }

    // Process if OnBarUpdate is called for another indicator.
    if (BarsInProgress == 1)
    {
    Print("BarsInProgress == 1");
    }

    Comment


      #3
      Originally posted by mgbloomfield View Post
      Have you read this?



      OnBarUpdate is called for each indicator you have added to a strategy.

      Try this...

      // Process if OnBarUpdate is called for one indicator.
      if (BarsInProgress == 0)
      {
      Print("BarsInProgress == 0");
      }

      // Process if OnBarUpdate is called for another indicator.
      if (BarsInProgress == 1)
      {
      Print("BarsInProgress == 1");
      }
      Ok, now I am completely confused. And I am still having issues.

      Yes, I read that post you gave me like 20 times. It's slowly seeping in. A lot to digest.

      So onBarUpdate() is called as per the indicator in the strategy and not as per the added instruments? So if I have additional instruments on different time frames, I don't get an OnBarUpdate for each added time/instrument?

      It would be nice if there was some visuals for a lot of the NT concepts. It's very difficult to wrap one's mind around some of the concepts. For example, when do you need to sync a DataSeries and when not? Confusing. I am sure it will all come to me sooner or later, but grasping this is a bear at the moment.

      By the way, thank you for helping. I am going to re-read the BarInProgress thread again.

      Comment


        #4
        Originally posted by r2kTrader View Post
        So onBarUpdate() is called as per the indicator in the strategy and not as per the added instruments? So if I have additional instruments on different time frames, I don't get an OnBarUpdate for each added time/instrument?
        Let me rephrase what I said... I misquoted...

        Instead of saying, "OnBarUpdate is called for each indicator you have added to a strategy", I should've said, "OnBarUpdate is called for each instrument you have added to a strategy".

        Another helpful article is... http://www.ninjatrader-support.com/H...ameInstruments

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, Yesterday, 01:02 PM
        0 responses
        29 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        21 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        160 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        95 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        148 views
        2 likes
        Last Post CaptainJack  
        Working...
        X