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

Unable to Add 60 minute bars data on a 15 minute strategy

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

    Unable to Add 60 minute bars data on a 15 minute strategy

    Hi,

    I am trying to add additional data series for my 15 minute strategy but 60 minute data is not working.
    The main parts of code are as follows:

    #region Variables
    private int tickCount = 0;
    #endregion

    protected override void Initialize()
    {
    //add all other time-frames
    Add(PeriodType.Minute, 5);
    Add(PeriodType.Minute, 30);
    Add(PeriodType.Minute, 60);

    CalculateOnBarClose = false;
    }

    protected override void OnBarUpdate()
    {
    tickCount++;

    Print(tickCount+" > BarsInProgress: "+BarsInProgress);
    }

    In the output window I get this:
    ....
    8467 > BarsInProgress: 0
    8468 > BarsInProgress: 1
    8469 > BarsInProgress: 2
    8470 > BarsInProgress: 0
    8471 > BarsInProgress: 1
    8472 > BarsInProgress: 2
    8473 > BarsInProgress: 0
    8474 > BarsInProgress: 1
    8475 > BarsInProgress: 2
    ....

    "BarsInProgress: 3" is never printed. The system never sends 60 minute bar data even if I try to force it.
    Can you please suggest what should be solution to this ? I am using NinjaTrader 7

    #2
    Also want to clarify this is not the entire code for strategy, but just a debug version to see what the issue is. It seems the reason Strategy didn't work with 60 minute data is it never receives the triggers for 60m minute bars...

    Comment


      #3
      Hello Ash101, thanks for your post.

      I attached a test script that works on all added data series on my PC. Can you please import this and test?

      Best regards.
      Attached Files
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        I tried your script, but it gave me the same results as mine. Only Primary, 5 and 30 minutes printed. It did print the Historical values for 60 minute, but if you set CalculateOnBarClose = false, 60 minute data for each tick is not displayed.

        Comment


          #5
          Hello Ash101,

          CalculateOnBarClose is always true in historical data.


          May I confirm that this is being tested in real-time and not historical?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            My post above says CalculateOnBarClose = false. Its being tested in Market Replay connection. It works in Live data connection but does in Replay. But I need to test my strategy first. So that's why im using replay connection.

            Comment


              #7
              Typo above. Mean to say *does not work in Replay connection

              Comment


                #8
                Hello Ash101,

                Which post above is referencing the Market Replay connection?

                I've added CalculateOnBarClose = false to Chris' test script and tested and I am finding there are prints for BarsInProgress 3.

                Below is a link to a short video of the test.

                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi. Thanks for your reply. Im sure it works on your end. Probably some local issues here. I'll reinstall Ninjatrader and see if that fixes the issue for replay connection add data series. Otherwise i'll test it on live connection. No big deal. Thank you !

                  Comment


                    #10
                    Hello Ash101,

                    Did you change CalculateOnBarClose after running the script once?

                    Did you remove and re-add the instance of the strategy after changing default settings (anything set in Initialize())?
                    (What is CalculateOnBarClose set to in the Strategy window for the actual instance?)

                    Default settings are only applied when a new instance is added.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi ChelseaB. Below is my Initialize method of Strategy:

                      protected override void Initialize()
                      {
                      CalculateOnBarClose = false;

                      //add all other time-frames
                      Add(PeriodType.Minute, 5);
                      Add(PeriodType.Minute, 30);
                      Add(PeriodType.Minute, 60);
                      }

                      So CalculateOnBarClose is always false in the code. I also verified in Strategy Window that it is showing false.
                      Yes Remove and re-add multiple times a day.

                      Anyway for now I have coded a workaround where it uses TCP-IP for communicating the values from 60 minute Chart Cutom Indicator. Although it is clumsy and I wish Add Data Series worked for me in Replay as its much more elegant. But I had to finish this strategy and do testing, so i'll rely on the workaround for now and later change it... Thanks.

                      Comment


                        #12
                        Hello Ash101,

                        The video I have provided you demonstrates the behavior when the settings are correct.

                        May I have a video demonstrating adding a new instance of the script with CalculateOnBarClose set to false and BarsInProgress 3 not appearing, similar to the video I have created for you?

                        If you do not have software to record videos, Jing makes a tool that allows for 5 minute videos. Below is a public link.
                        TechSmith Capture is a simple, free way to create basic screenshots and screen recordings and share them with others.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Here is a link to the video that I took this afternoon to capture the issue we have been discussing. This time it was even worse as you can see in the video, none of the other time periods were called on the OnBarUpdate except only the primary time period:

                          video, sharing, camera phone, video phone, free, upload

                          Comment


                            #14
                            Hello Ash101,

                            I see you have chosen not to use the script Chris provided you and you are testing a different script with similar code.

                            I'd like to schedule a call with you so that I may test Chris' script on your end.

                            Please send an email to platformsupport [at] ninjatrader [dot] com. In the email please include a link to this forum thread.

                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              I had deleted Chris's script as its behavior did not differ from mine. The entire code is in the video and there is practically nothing being done in the code except printing BarsInProgreess for each tick. I'll post another video after re-downloading Chris's script. And also send you an email to have a call. But I suspect there is some issue in the Replay connection. Sometimes the issue appears and sometimes it doesn't for different time periods Data Series. But I never had 60 minute DatSeries work in Replay connection. Even 30 minutes has some issues. I have noticed that the number of days of replay data affects how this behaves. So if I have five days of Historical data, the first day's behavior will be worse vs the 3rd or 4th days if I play them all in series. But I never had 60 minutes work for me. I'll re-post a video with Chris's script...

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Gerik, Today, 09:40 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post Gerik
                              by Gerik
                               
                              Started by RookieTrader, Today, 09:37 AM
                              2 responses
                              11 views
                              0 likes
                              Last Post RookieTrader  
                              Started by alifarahani, Today, 09:40 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by KennyK, 05-29-2017, 02:02 AM
                              3 responses
                              1,285 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              11 responses
                              186 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X