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 a bar with different time interval

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

    adding a bar with different time interval

    in my Strategy subclass 's Initialize() , I called
    Add(PeriodType.Minute, 5);

    What is the bar index for the bar I have added inside Initialize() method ?

    Once I know the index value, can I access it using

    this.BarsArray[index][0] // inside OnBarUpdate

    #2
    Not sure I follow 100% your question but I can provide the following...

    The primary series your strategy runs on as determined when applying your strategy to a chart is index 0. Each subsequent call to the Add() method to add a series will be incremented by one.

    Add(PeriodType.Minute, 5); // Would have index 1
    Add(PeriodType.Minute, 6); // Would have index 2
    RayNinjaTrader Customer Service

    Comment


      #3
      if there are indicators already on the chart

      if there are indicators already on the chart , what will be the index number for the my added bar ?

      Comment


        #4
        Adding indicators does not impact the indexing of bars, thus my original response is still accurate.
        RayNinjaTrader Customer Service

        Comment


          #5
          Add PeriodType.Minute 1 minute on a 10 minute Chart

          I have opened up a 10 minute Chart , and in my custom Strategy I added a minute series in the Initialize() method as follow:

          protected override void Initialize()
          {
          this.Add(PeriodType.Minute, 1);
          }

          Then I do some checking in the OnBarUpdate() .

          protected override void OnBarUpdate()
          {
          Period checkPeriod = this.BarsArray[this.BarsInProgress].Period;
          if (checkPeriod.Id != PeriodType.Minute
          || checkPeriod.Value != 1)
          {
          return;
          }
          // do my other stuff
          }

          It check to ensure it is a one minute bar. To my surprise , there is no 1 minute bar , so the check step above will always reject the bar update event.

          I am using NT 6.5 .

          Is it possible to get 1 minute data even if the Chart is 10 minutes ?

          Comment


            #6
            To confirm that there really is one minute bars, do this:

            if (BarsInProgress == 1) Print(Time[0].ToString());

            This will confirm that when OnBarUpdate() is called for the second series (your one minute bar) it will print the bar time stamp to the output window.
            RayNinjaTrader Customer Service

            Comment


              #7
              I have imported minutes by minutes historical data into NT 6.5 for 12/1/2008 to 12/31/2008 .
              I printed the active bar on every OnBarUpdate() as follow:

              this.Print(this.Times[this.BarsInProgress][0].ToString() + " BarsInProgress="+this.BarsInProgress+ " Period " + this.BarsArray[this.BarsInProgress].Period.ToString());

              If I create 20 minutes chart and load my strategy. The first time it load (by clicking NEW , then OK ) .. The Output windows shows no 1 minutes bar activity. It starts at 12/1/2008 which is strange :

              12/3/2008 8:00:00 AM BarsInProgress=0 Period 20 Min
              12/3/2008 8:20:00 AM BarsInProgress=0 Period 20 Min
              12/3/2008 8:40:00 AM BarsInProgress=0 Period 20 Min
              12/3/2008 9:00:00 AM BarsInProgress=0 Period 20 Min
              12/3/2008 9:20:00 AM BarsInProgress=0 Period 20 Min
              12/3/2008 9:40:00 AM BarsInProgress=0 Period 20 Min
              ......... etc

              If I do not close the chart and load the strategy again , I get some 1 minute activity. But it starts at 12/3/2008 which is a Wednesday. Why 12/1/2008 is missing ?

              12/3/2008 8:00:00 AM BarsInProgress=0 Period 20 Min
              12/3/2008 8:00:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:01:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:02:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:03:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:04:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:05:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:06:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:07:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:08:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:09:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:10:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:11:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:12:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:13:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:14:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:15:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:16:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:17:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:18:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:19:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:20:00 AM BarsInProgress=0 Period 20 Min
              12/3/2008 8:20:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:21:00 AM BarsInProgress=1 Period 1 Min
              12/3/2008 8:22:00 AM BarsInProgress=1 Period 1 Min

              Comment


                #8
                If I create a 1 minutes chart , then the 12/1/2008 shows up:

                12/1/2008 8:20:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:21:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:22:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:23:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:24:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:25:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:26:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:27:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:28:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:29:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:30:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:31:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:32:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:33:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:34:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:35:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:36:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:37:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:38:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:39:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:40:00 AM BarsInProgress=0 Period 1 Min
                12/1/2008 8:41:00 AM BarsInProgress=0 Period 1 Min

                Comment


                  #9
                  so why 12/1/2008 is missing when I use the 20 minutes chart ? I have make sure I selected 12/1/2008 as the start date when I create the charts..

                  Comment


                    #10
                    Please recheck with your MinBarsRequired set to 0 as you start up the MulriSeries strategy, the strategy would start processing if the Min bars required is satisfied for all referenced series in it.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by michi08, 10-05-2018, 09:31 AM
                    2 responses
                    738 views
                    0 likes
                    Last Post Denver_Wayne  
                    Started by sightcareclickhere, Today, 01:55 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post sightcareclickhere  
                    Started by Mindset, 05-06-2023, 09:03 PM
                    9 responses
                    258 views
                    0 likes
                    Last Post ender_wiggum  
                    Started by Mizzouman1, Today, 07:35 AM
                    4 responses
                    18 views
                    0 likes
                    Last Post Mizzouman1  
                    Started by philmg, Today, 01:17 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_ChristopherJ  
                    Working...
                    X