Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Logical error handling for checking whether any bars were processed

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

    Logical error handling for checking whether any bars were processed

    I keep running into a situation which causes me to lose a lot of time unnecessarily and I want to put some error checking into my strategy to notify me immediatly of the situation.

    With a multi-instrument strategy, I often set dates for the strategy in the Strategy Analyzer when no historical data for one or sometimes even all of the instruments exists in the Historical Data Manager.

    Firstly I need to recognise that this was the problem - sometimes I spend time checking other things unnecessarily - and secondly I would like to flag up which Bars in my set of instruments didn't have any data (the Historical Data Manager is v slow when looking at tick data).

    I can't find any direct way to see if the Bars object has no content or any method that might help.

    Thanks

    #2
    Sorry, massive blind spot! It must be the Count property, right? I'm just going to check it.

    Comment


      #3
      Actually I am running the check on the BarsArray[x].Count in onTermination().

      Is that logical? Or is onTermination() not called when no bars are processed, or without the double negative, is it only called when bars are processed?

      Comment


        #4
        Hello,

        Yes this will work when running the strategy live or simulated live. However in my test if there are no bars to run on the strategy never does start, therefor OnTermination() is not run when running on a backtest.


        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Hi Brett, thanks for the info. Is there any way I can detect that situation in the Initialize() event? (when there are no bars to run on)

          In fact it sounds as if the Initialize() event then is the only event to fire in a strategy if there are no bars to run. Is that correct?

          Comment


            #6
            Unfortunately there is no way to detect it.
            Initialize() will be the only normal method to run, yes.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thanks. When you say "normal" method, do you mean by 'normal' that there are other methods, but you don't support them?

              Comment


                #8
                Yes, there are methods we do not support like overriding the Plot() method.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                633 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                364 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                567 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                568 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X