Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Day Data File Reference Issue

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

    Day Data File Reference Issue

    I'm running a strategy that uses 2 timeframes, 1 minute and 1 day. I've narrowed the problem down to NT not referencing the day data file by using the Print statement. I've googled and also seen that others had this issue. Do you guys know what to do? I cannot post the strategy as it is confidential. It is not due to BarsInProgress or anything like that, I narrowed it all the way down to running a default strategy created by the wizard and then unlocked, using 1 min as primary and referencing 1 day data. It will not reference the day data file.

    Thanks

    #2
    Hello albazzaztariq,

    Thanks for your post.

    Are you able to post the simplified code that you have been able to duplicate this with just the strategy wizard then adding the 1 day data?
    BrandonNinjaTrader Customer Service

    Comment


      #3
      public class Tony : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int offer = 1; // Default setting for Offer
      private int bid = 1; // Default setting for Bid
      private int stop = 1; // Default setting for Stop
      // User defined variables (add any user defined variables below)
      #endregion
      double OpenNatty;

      protected override void Initialize()
      {
      Add(PeriodType.Day,1);
      CalculateOnBarClose = true;
      }

      protected override void OnBarUpdate()
      {

      OpenNatty = Opens[1][0];
      Print(OpenNatty);
      Print(5+5);

      }
      }

      Comment


        #4
        Hello albazzaztariq,

        Thanks for your reply.

        To have it get the current days open you would need to change your strategy to have Calculate On Bar Close set to False.
        BrandonNinjaTrader Customer Service

        Comment


          #5
          This does not work. It doesn't work if I put CalcOnBarClose to true or false. The only time I can make it run the print statements is if I remove the additional time series (and thus the two-dimensional array). Is it something with the array referencing the day data files?

          Comment


            #6
            Hello albazzaztariq,

            Thanks for your reply.

            Please try increasing the Days To Load on your chart.
            Right click on your chart and select Data Series to set the Days To Load
            BrandonNinjaTrader Customer Service

            Comment


              #7
              This is not a chart. This is a backtest in Strategy Analyzer

              Comment


                #8
                Hello albazzaztariq,

                Thanks for your reply.

                Since you are running this on a minute chart what you may want to do for the best performance and results is add a 1440 minute time frame rather than a 1 day (there are 1440 minutes in a day)
                BrandonNinjaTrader Customer Service

                Comment


                  #9
                  This will not fix the problem. There is some bad minute data with missing prints, etc. I need the open high low and close of the day. I would rather not simply try to circumvent the problem. I want to use the day data along with minute.

                  Comment


                    #10
                    Hello albazzaztariq,

                    The 1440 Minute Series is usually good to use since you are already loading up Minute Data as well as you are able to control the Session of the 1440 Minute Series.

                    With that said, if you want to use Day this should be fine. I suspect that this is either going to be due to an error, no Daily Data, or a "Min bars required" or "BarsRequired" that is throwing off what you would expect.

                    If it was an error in your strategy you should see this inside of the Log tab of the Strategy Analyzer. You may see something like "You are accessing an index with a value that is invalid since its out of range".

                    To check to see if you have Daily data you may check this inside of the Historical Data Manager under Tools -> Historical Data Manager -> Edit tab.




                    My guess would be the "Min Bars Required" or "BarsRequired" setting of your Strategy. If you have verified that you have data and you are not getting an error you may want to change the "Min bars required" setting inside of your Strategy Parameters to 0 and try this again.

                    Note that you may want to add:

                    protected override void OnBarUpdate()
                    {
                    // Checks to ensure all Bars objects contain enough bars before beginning
                    if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
                    return;
                    //rest of code
                    }

                    To make sure that you do not get an error.

                    Let me know if that makes your strategy work more like what you are expecting.
                    JCNinjaTrader Customer Service

                    Comment


                      #11
                      It was min bars required. Thanks. Using the 1440 min wouldn't work because there were missing prints and I need the open, high, low, and close for the trading day. These were not correct with the minute data but were with day data. That is why I need the day data. Thank you

                      Comment


                        #12
                        if (ToTime(Time[0]) == ToTime(18,00,00))
                        {
                        OpenNC = Opens[1][0];
                        Print(OpenNC);
                        Print(5+5);
                        }

                        Why when I add the time variable will it no longer print?

                        Comment


                          #13
                          Nevermind, I fixed it

                          Comment


                            #14
                            The open for natural gas is @ 6 PM. Going back to what I said before "nevermind", I said why does this not work...

                            if (ToTime(Time[0]) == ToTime(18,00,00))
                            {
                            OpenNC = Opens[1][0];
                            Print(OpenNC);
                            Print(5+5);
                            }

                            at 6 pm, why can it not pull in the open of the bar data from the day data? I even change it to 1 second after and it will not do it. If I change it to 6:01 PM, it works, but this is too late.

                            Comment


                              #15
                              Hello albazzaztariq,

                              This can be due to either the BarsInProgress or BIP has not occurred yet for the Day Data Series or most likely due to the Bar time stamp. NinjaTrader is going to report back the Time[0] for close time of the bar meaning that data from 6:00:00 PM to 6:00:59 PM is going to be reported on the 6:01 PM Bar time stamp.

                              In real-time if you have CalculateOnBarClose (COBC) set to false using a Minute chart you will want to get the 6:01 PM bar as it is forming since it will get you the data that you are looking for.

                              For more information about the Time Stamps of a bar you may view our Help Guide at the following link under "Understanding the variables involved in building chart bars".


                              Let me know if you have any further questions as I would be happy to clarify.
                              JCNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jclose, Today, 09:37 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post jclose
                              by jclose
                               
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              10 responses
                              1,413 views
                              0 likes
                              Last Post Traderontheroad  
                              Started by firefoxforum12, Today, 08:53 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post firefoxforum12  
                              Started by stafe, Today, 08:34 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post stafe
                              by stafe
                               
                              Started by sastrades, 01-31-2024, 10:19 PM
                              11 responses
                              169 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X