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

MTF indicator crashes by changing number of dataseries

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

    MTF indicator crashes by changing number of dataseries

    Hey,

    I'm developing an indicator which calculates different things on multiple timeframes. Therefore I'm calling the Add method in the initialize method as described everywhere. Here the heavy reduced code:

    Code:
    protected override void Initialize()
    {
    try
    {
    Add(PeriodType.Day, 1);
    }
    catch  (Exception e)
    {
    }
    But the problem is that it is quite dynamically how many dataseries are added in the initialize method based on an user input. So the Add happens in a loop. Everything works perfectly as long as the number of the dataseries are not getting reduced in contrast to the last used number of dataseries.

    For example the standard value for variable lets create 5 dataseries. I can change this parameter of the indicator and add a sixt one. But then I cannot change it back to five or I cannot change it in the beginning to four dataseries as the initialize method gets called very early and has already created five dataseries.

    As soon as I try to reduce it the chart keeps blank without any error or anything.
    Can somebody help me how to approach this problem?

    Thank you very much,

    Araksor

    #2
    Hello Araksor,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    I am not sure what the intent behind the loop would be but you could use something like the following without a loop:
    Code:
    		#region Variables
    		private int numberOfBarSeries = 0;
    		#endregion
    
    		protected override void Initialize()
    		{			
    			if(numberOfBarSeries > 0)
    				Add(PeriodType.Minute, 15);
    			if(numberOfBarSeries > 1)
    				Add(PeriodType.Minute, 30);
    			if(numberOfBarSeries > 2)
    				Add(PeriodType.Minute, 45);
    		}
    Please let me know you have any questions.

    Comment


      #3
      Hello PatrickH,

      Thank you for your fast help!

      Of course I could do that but the loop does not seem to be problem as it is working perfectly at first startup with the 5 dataseries. I did not post my intention in the previous post because I think it has nothing to do with my problem but here it is:

      The user submitts a string via a parameter where he can specify the number of dataseries and which periods they should have. For example: "30s;1m;15m;60m;240m;1d" would create 6 dataseries, one with 30 seconds as Period Type, one with 1 minute, one with 15 minutes, one with 60 minutes, one with 240 minutes, one with daily bars.
      I am calculating different things on the dataseries (i.e. RSI, MACD, Fibonacci Retracements, EMA, ...) and show them all together in a grid in the Panel.
      That works all perfect and I do not have any problems with that. The only problem is to remove created dataseries and they are already created in the initialize method. Is it possible to create them in the OnStartUp Method? Maybe that would help.

      Further I could change my default value for the dataseries in a way that only one exists after Initialize but that is a crappy solution as the indicator would have be to removed and added again to reduce the number of dataseries.

      *Edit
      In fact I would just need a solution to create the indicator with the changed parameter as it would be created if that was the default value.

      Best regards,

      Araksor
      Last edited by Araksor; 11-05-2013, 01:45 AM.

      Comment


        #4
        Hello Araksor,

        Thank you for your response.

        Even with my example this will not work after the first time you enter the parameters. So we can start with two additional bar series for example but once we try to change this to one or any other number it will not load the chart. Unfortunately, there is no work around for this item.

        Please let me know if you have any questions.

        Comment


          #5
          Okay, then I will just create 20 dataseries and only use x of them and reset their period types and values.
          Is it better for performance to use big periods like weeks or months? I don't want to loose that much performance. Of course I will ignore them for any calculations.

          Thank you PatrickH!

          Comment


            #6
            Hello Araksor,

            Thank you for your response.

            Larger Period Types will have less data to load for the time frame used (DaysToLoad), this will be less demand on the PC.

            Please let me know if I may be of further assistance.

            Comment


              #7
              Thank you!

              That's all.

              Best,

              Araksor

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mestor, 03-10-2023, 01:50 AM
              14 responses
              375 views
              0 likes
              Last Post z.franck  
              Started by molecool, 10-09-2017, 10:48 AM
              5 responses
              1,621 views
              0 likes
              Last Post trader-ap  
              Started by The_Sec, Yesterday, 03:53 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by mmenigma, Yesterday, 03:25 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by kujista, Today, 05:44 AM
              0 responses
              7 views
              0 likes
              Last Post kujista
              by kujista
               
              Working...
              X