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

Add(Instrument.Fullname... - How to Remove?

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

    Add(Instrument.Fullname... - How to Remove?

    Hi

    I have some code where I want to use 1 tick historical data but when I get to real-time data, I don't need it.

    So - in the initialize section, I do the following:

    Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Last);


    Now, at some point, I'd like to kill the feed. It's obviously slowing things down for me.


    So - can I "Remove" the instrument?


    Cheers


    Pete

    #2
    Hi Pete,

    There's unfortunately no way to remove the added series at run time. Best you could do is prevent processing on any of the added bar objects with something like:

    if (!Historical && BarsInProgress == 1) return;
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan

      I have that in there - it seems to be the actual feed itself that's slowing things down.

      If I am already using a 40 tick chart, would adding this feed for the same instrument cause any additional load? Would it download the data in a separate feed for instance?

      Cheers

      Pete

      Comment


        #4
        same issue here....

        Comment


          #5
          Originally posted by daytradeblogger View Post
          same issue here....
          Same performance issue?

          It's quite drastic on my machine - and this is a speedy i7...

          Comment


            #6
            It will not be a separate data stream but once it's been added, it will be loaded into memory. It should be a comparable resource hit to creating a 1 tick chart. I'd be happy to take a look at your trace file to see if there are other things that may be contributing to performance here. Please send to my attention at support 'at' ninjatrader 'dot' com.

            You will find the trace file in the Documents > NinjaTrader 7 > Trace folder.
            The trace file will be named "trace.YYYYMMDD.txt"
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              use the static NinjaTrader.Data.Bars.GetBars(....)

              use it in OnStartUp, do the calculations from those bars and dispose it. for the rest of the tick based calculations do it in OnMarketData or whatever.

              Comment


                #8
                Bukkan - I'll give that a go - many thanks!

                Comment


                  #9
                  Originally posted by NinjaTrader_RyanM View Post
                  It will not be a separate data stream but once it's been added, it will be loaded into memory. It should be a comparable resource hit to creating a 1 tick chart. I'd be happy to take a look at your trace file to see if there are other things that may be contributing to performance here. Please send to my attention at support 'at' ninjatrader 'dot' com.

                  You will find the trace file in the Documents > NinjaTrader 7 > Trace folder.
                  The trace file will be named "trace.YYYYMMDD.txt"
                  Will do - just as soon as I get a live market again...

                  Comment


                    #10
                    Bukkan

                    As this is an undocumented feature - any ideas on how to use that method to get all the 1 tick bars since the current session opened?

                    BTW - All I'm trying to do here is build up a volume profile - trades @ each price level.

                    Thanks

                    Pete

                    Comment


                      #11
                      it will be something like this

                      Code:
                      Bars bars = NinjaTrader.Data.Bars.GetBars(Instrument,new Period(PeriodType.Tick,1,MarketDataType.Last), DateTime.Now.AddDays(-7),DateTime.Now,BarsArray[0].Session,false,false); //will get tick data for the last 7 days
                                      
                      if (bars != null && bars.Count > 0)
                      {
                      //do your stuff
                      }
                      since you are pulling tickdata "days to load" is a thing you should consider and use judiciously.

                      I used the session as used in the primary bar.

                      i did some stuffs on VP using this, but since i was building my stuff for the Indian markets and where the data is not as huge as ES etc i revert back to the multi instrument stuff. otherwise the above code worked fine for vp.

                      Comment


                        #12
                        Bukkan

                        Many thanks for that but I'm still not sure how to access the actual bars...

                        Here's what I tried.

                        Code:
                        			Bars myBars = NinjaTrader.Data.Bars.GetBars(Instrument,new Period(PeriodType.Tick,1,MarketDataType.Last), DateTime.Now.AddDays(-1),DateTime.Now,BarsArray[0].Session,false,false); //will get tick data for the last 7 days
                        			for (ii = 0; ii < myBars.Count; ii++);
                        			{
                        				if (myBars[ii].FirstBarOfSession == true)
                        				{	
                        					// Reset the array
                        					Array.Clear(volumeProfile,0,4000);
                        					// get the tick size
                        					tickSize = Instrument.MasterInstrument.TickSize;	
                        					tickMult = 1 / tickSize;
                        					startPrice = myBars[ii].Close - (2000 * tickSize);				
                        				}		
                        				int myRow = Convert.ToInt16((myBars.Close[ii] - startPrice) * tickMult);
                        				if (myRow >= 0 && myRow <= 4000)
                        				{
                        					volumeProfile[myRow] +=   myBars[ii].Volume;
                        				}
                        			}
                        Basically, I tried to use myBars as a list and page through the list. Hence the myBars[]ii] stiff. That doesn't appear to work.

                        So - how do I actually access the bar data once the series is added?

                        Many thanks

                        Pete

                        Comment


                          #13
                          Originally posted by NinjaTrader_RyanM View Post
                          It will not be a separate data stream but once it's been added, it will be loaded into memory. It should be a comparable resource hit to creating a 1 tick chart. I'd be happy to take a look at your trace file to see if there are other things that may be contributing to performance here. Please send to my attention at support 'at' ninjatrader 'dot' com.

                          You will find the trace file in the Documents > NinjaTrader 7 > Trace folder.
                          The trace file will be named "trace.YYYYMMDD.txt"
                          The problem is Ryan, that once the new data stream is added, even though it's the same instrument, both data series trigger the onMarketData & onMarketDepth events.

                          From what I can see there is no way to tell onMarketData or onMarketDepth to ignore one of the price series.

                          So - this is where the performance hit comes in for me.

                          Pete

                          Comment


                            #14
                            Code:
                            for (int i = 0; i < bars.Count; i++)
                            {
                                 if (bars.Get(i).FirstBarOfSession)
                                                 Print(bars.GetClose(i);
                            }

                            Comment


                              #15
                              Bukkan

                              Fantastic - works great.

                              Many thanks

                              Pete

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GLFX005, Today, 03:23 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post GLFX005
                              by GLFX005
                               
                              Started by XXtrader, Yesterday, 11:30 PM
                              2 responses
                              11 views
                              0 likes
                              Last Post XXtrader  
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by TradeForge, Today, 02:09 AM
                              0 responses
                              14 views
                              0 likes
                              Last Post TradeForge  
                              Started by Waxavi, Today, 02:00 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Working...
                              X