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

Reading Days To Load from within strategy?

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

    Reading Days To Load from within strategy?

    Hi

    Is it possible to read what "Days to load" is set to from within a strategy, perhaps with Initialize() or OnStartUp()? This would be useful to alert the user if it was set to a value too small.

    Regards
    Tony

    #2
    Hello,

    While not supported, you can use Bars.BarsData to find this property:

    Code:
    		protected override void OnStartUp()
    		{			
    			Print(Bars.BarsData.DaysBack);
    		}
    Last edited by NinjaTrader_Matthew; 11-21-2012, 02:02 PM.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by Jellybean View Post
      Hi

      Is it possible to read what "Days to load" is set to from within a strategy, perhaps with Initialize() or OnStartUp()? This would be useful to alert the user if it was set to a value too small.

      Regards
      Tony
      Your question is clear as stated, but is that really what you are seeking? IOW, do you want to know what "Days to load" is set to, or are you really wanting to know how many days have actually been loaded on the chart?

      Comment


        #4
        Good question, Koganam.

        I really want to be sure that enough data is loaded to calculate a 200-day SMA in a strategy that operates on 1 min bars.

        The primary bars object is 1 min (TF 12-12) and I add the series for daily bars.

        I tried testing CurrentBars[1] when Historical is false, but I found that Historical is sometimes false even when historical bars of BarsArray[1] are being processed. I wanted to detect the situation where the user has loaded not enough days, but the test of CurrentBars[1] would always occur too early and indicate not enough data, even if "Days to load" was correct. There has been some discussion on this forum about it (related to the settings of "Days to load" and "Min. bars required"), but I couldn't figure out how it all worked.

        By checking that "Days to load" is set to a high enough value, at least I can prompt the user if they have set it incorrectly.

        That is fine for my purpose, but is there a better way?

        Cheers
        Tony

        Comment


          #5
          Originally posted by Jellybean View Post
          Good question, Koganam.

          I really want to be sure that enough data is loaded to calculate a 200-day SMA in a strategy that operates on 1 min bars.

          The primary bars object is 1 min (TF 12-12) and I add the series for daily bars.

          I tried testing CurrentBars[1] when Historical is false, but I found that Historical is sometimes false even when historical bars of BarsArray[1] are being processed. I wanted to detect the situation where the user has loaded not enough days, but the test of CurrentBars[1] would always occur too early and indicate not enough data, even if "Days to load" was correct. There has been some discussion on this forum about it (related to the settings of "Days to load" and "Min. bars required"), but I couldn't figure out how it all worked.

          By checking that "Days to load" is set to a high enough value, at least I can prompt the user if they have set it incorrectly.

          That is fine for my purpose, but is there a better way?

          Cheers
          Tony
          "Days to load" is merely a directive/request to load data. It may or may not match what is actually loaded. If your output depends on days loaded (not "to load"). then you should be looking at the days that are actually loaded.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by popecapllc, 08-09-2023, 07:42 PM
          8 responses
          1,338 views
          0 likes
          Last Post Johng22
          by Johng22
           
          Started by ETFVoyageur, 04-30-2024, 02:04 PM
          11 responses
          99 views
          0 likes
          Last Post ETFVoyageur  
          Started by bubblegum, 03-18-2024, 10:41 AM
          3 responses
          44 views
          0 likes
          Last Post vjsworld  
          Started by JamesK1, Today, 02:48 PM
          1 response
          12 views
          0 likes
          Last Post JamesK1
          by JamesK1
           
          Started by llanqui, Today, 03:51 PM
          0 responses
          10 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Working...
          X