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

Indicator need ages to load / be applied to the chart

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

    Indicator need ages to load / be applied to the chart

    Hi. I just got into programming a couple of weeks ago, so im fairly new to this.

    i just started with some basic stuff and gradually improved it over time. especially my "main project" got really big (codewise) in the last weeks, which caused to keep loading slower and slower the more code i added.

    now, while every common indiactor loads within seconds, this one needs around 4-5 minutes for a decent amount of data, wich is painful enough if you just wanna work with it. but if ur actually working ON it and need to check ur changes on the chart, this waiting time is a pain in the ***.
    not to mention that i have technically a really strong pc.

    i was wondering if there is any information out there
    what code is actually very calculationheavy or how to optimize code so it requires the least amount of resources.

    i dont know, its not really i problem that i can tackle by browing through the help center.

    also, since my onbarupdate part is already 300 lines long, would it help to split this into diffrent indicators and access it with boolseries
    ninjatrader wuld still have to do the same stuff on every bar tho, so i guess not?


    any help is welcome.

    #2
    Hello,

    There are a few areas you can check in your code that may be allocating more resources than intended.

    Extremely liberal use of Log() and Print() methods can represent a performance hit on your PC as it takes memory and time to process each one of those method calls. When running custom NinjaScript, especially when using CalculateOnBarClose = false, please be mindful of how often Log() and Print() methods are processed as it can quickly consume PC resources. •Log() method should not be used except for critical messages as each log entry makes it to the Control Center log which stays active till the end of the day. Excessive logging can result in huge amounts of memory being allocated just to display all the log messages which would mean less memory for NinjaTrader to do other tasks. •Print() method can be used more liberally than the Log() method, but can still represent a performance hit if used with extremely high frequency. Consider decreasing the printing from your script if you experience slowdowns when running the script.

    Also, please also ensure you do not have Debug Mode enabled as it can lead to lower performance. To disable, right mouse click in any NinjaScript Editor and uncheck the "Debug Mode" menu item.

    After doing so, press F5 to recompile. There are also chart settings that could effect the performance of your scripts. I would suggest reducing the amount of Drawing objects being used if there are any. There is also the option of Days to Load, Bars to Load and Custom Range options in your Data Series Properties. These values should be adjusted to load less data in your charts and free up resources.
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      sadly i dont use any prints or logs. debug is also off. and im running on barclose
      the only thing that im doin rather heavily is drawing, but thats kinda the point of this whole thing.

      i saw some indicators use some "plot" syntax to draw stuff instead of "drawline" or whatever. would that improve performance?

      plus loading less data is not really an option since its already at a practial minimum. anything les would require constant change of the daterange which also would lead to big loading times if ud sum that up.
      Last edited by BigRo; 10-08-2015, 08:21 AM.

      Comment


        #4
        Hello,


        They are both similar in terms of performance.


        Plot() and DrawLine() are used for different purposes. The one you use would have to be the one that you think fits best for your conditions.
        Shawn B.NinjaTrader Customer Service

        Comment


          #5
          If you use Draw() methods, it will definitely slow down your chart. This is particulary true, if you use charts with extended lookback periods and/or high resolution.

          I have replaced DrawRegion() in many of my indicators with a custom plot. In some cases this brought down chart loading times from 30 seconds to 1 second.

          I recommend to use Plots and to avoid any of the NinjaScript Draw() methods whenever possible.

          Comment


            #6
            Originally posted by BigRo View Post
            sadly i dont use any prints or logs. debug is also off. and im running on barclose
            the only thing that im doin rather heavily is drawing, but thats kinda the point of this whole thing.

            i saw some indicators use some "plot" syntax to draw stuff instead of "drawline" or whatever. would that improve performance?

            plus loading less data is not really an option since its already at a practial minimum. anything les would require constant change of the daterange which also would lead to big loading times if ud sum that up.
            Is it necessary for your indicator to be looking through every historical bar when it loads? If not you should stop your indicator from doing anything until it gets to the last bar by putting this as your first line in your OnBarUpdate sequence.

            if (CurrentBar < Count - 2)return;

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Irukandji, Today, 09:34 AM
            0 responses
            3 views
            0 likes
            Last Post Irukandji  
            Started by TraderBCL, Today, 04:38 AM
            3 responses
            25 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            11 responses
            1,423 views
            0 likes
            Last Post jculp
            by jculp
             
            Started by RubenCazorla, Today, 09:07 AM
            0 responses
            4 views
            0 likes
            Last Post RubenCazorla  
            Started by BarzTrading, Today, 07:25 AM
            2 responses
            29 views
            1 like
            Last Post BarzTrading  
            Working...
            X