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

adding daily bars doesn't hit breakpoint in OnBarUpdate

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

    adding daily bars doesn't hit breakpoint in OnBarUpdate

    Hi,
    I'm running a strategy on 5-min data series. I've added Daily bars within the strategy, but my breakpoint in OnBarUpdate() method never gets hit for this daily bars.
    Am I doing something wrong? Is there another way to capture the moment when daily bar is being closed?
    I actually need to run an indicator with daily bar data.

    Thanks

    #2
    Hello ivanjocic,

    OnBarUpdate will trigger for every series added to the script.

    To confirm, you have a condition that looks for BarsInProgress to be 1 and then prints the time of the bar and no prints are appearing with the historical data, is this correct?

    How many days are loading of the 5 minute series?

    Do you have a simplified test script to demonstrate the behavior?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for quick reply,
      I'm loading 30 days in 5-min chart, but my breakpoint on 'Print' line never gets hit although _idxLongPeriodBars get's filled correctly.

      Code:
      protected override void Initialize()
              {
               
                  Add(PeriodType.Minute, 1);
                  Add(PeriodType.Minute, _higherTimeframe);
                  Add(PeriodType.Minute, _lowerTimeframe);
                  Add(PeriodType.Day, 1);
                  
                  Overlay = true;
              }
      
      protected override void OnStartUp()
      {
                  // find appropriate time Bars
                  for (int i = BarsArray.Length - 1; i >= 1; i--)
                  {
                      if (BarsArray[i].Period.Id == PeriodType.Day
                          && BarsArray[i].Period.Value == 1)
                          _idxLongPeriodBars = i;
      		    }
                  }
      }
      protected override void OnBarUpdate()
      {
                  if (BarsInProgress == _idxLongPeriodBars)
                      Print("Hit");
      }

      Comment


        #4
        Hello ivanjocic,

        What is the value of _idxLongPeriodBars in OnBarUpdate?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          it's 4. Which is correct one, and CalculateOnBarClose = true.
          There's one thing to note, that is _lowerTimeFrame is again 5 minutes. So I have BarsArray[0] and BarsArray[2] equal(Minute, 5).
          Maybe that's causing this issue?
          Last edited by ivanjocic; 07-24-2017, 11:19 AM.

          Comment


            #6
            Hello ivanjocic,

            Thank you for confirming this.

            I am not able to reproduce this behavior.

            Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


            Attached is the script I have tested.

            If you test this script (without modifying it) on an ES 09-17 chart with 5 days to load, are you not getting any prints?
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Sorry,
              but I've made a mistake. I have a strategy on 5min data, but the code I've sent is in the indicator. Is this still working for you?
              Should I add 1 day bars also to the strategy?

              Comment


                #8
                Hello ivanjocic,

                I am not understanding what you are asking.

                Yes, the script I have exported with post #6 is still working for me.

                May I confirm you have tested the script I have provided you and you are getting different behavior?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Your code works. I have to figure it out then why mine does not.

                  Thank you for your patience.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RubenCazorla, Today, 09:07 AM
                  2 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by i019945nj, 12-14-2023, 06:41 AM
                  7 responses
                  81 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by timmbbo, 07-05-2023, 10:21 PM
                  4 responses
                  158 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by tkaboris, Today, 08:01 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by Lumbeezl, 01-11-2022, 06:50 PM
                  31 responses
                  819 views
                  1 like
                  Last Post NinjaTrader_Adrian  
                  Working...
                  X