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 calculation is very slowly

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

    Indicator calculation is very slowly

    hey everybody, I have the problem, that my indicator has so many Data to calculate, that it becomes very slowly. it becomes that slowly, that it isnt possible to calculate 20 days of 1 minute.
    for example, i put the High, low, open close of every shortCandle in an long trend in a List and every candle a couple of Linq-Queries running throw this list. when there are more than 5k candles in this List, than i get problems with the calculation.
    How can I solve this poblem at NT or C#?

    may anybody give me an advice? thanks in advance.​

    #2
    Hello sane1111,

    Are you using loops?

    Are you calling AddDataSeries()?

    The price series, like High, Low, etc are already available and in memory for your script. Using these in conditions would have minimum impact on performance.

    Linq can be a little resource intensive. Does this query have to be run on every bar?

    Can you reduce the behavior to a specific line of code or a few specific lines of code that can reproduce the behavior?

    If so, can you provide an export of the reduced script that removes all logic not directly related to reproducing the behavior?

    To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message
    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
    Below is a link to the help guide on Exporting NinjaScripts.
    http://ninjatrader.com/support/helpG...-us/export.htm

    Once exported, please attach the file as an attachment to your reply.​
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you ninjatrader_chelseab,

      attached the zip. The other classes I also put in, that you can follow the construction. The problem starts at region MyPrice-Kind

      thanks for your help in advance!
      Attached Files
      Last edited by sane1111; 09-14-2022, 06:11 AM.

      Comment


        #4
        Hello sane1111,

        There is a lot of code in this.

        To confirm, you are already removed all code that can be removed and still produce the behavior?

        This as reduced as the script can get? If any code is removed the behavior can no longer be reproduced?

        For example on line 443, there is a Draw.ArrowUp() method call. If this line is removed, the behavior can no longer be reproduced?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Dear ninjatrader_chelseab thanks for your reply,

          yes the behaviour is still the same. And I´m on the beginning of this indicator. I would need a lot more methods like LevelBroken()

          Sorry I forgot to command out the lines 410, 411, 442, 443.

          What do you think, would the performance be better, when i export the Data to a DataBase, so that i only have to calculate it once?

          thanks for your answer in advance!

          Comment


            #6
            Hello sane1111,

            This would imply that this script has not been reduced to the specific lines of code causing the behavior. There is too much here. This is not a reduced script.

            If lines 255 and 256 are removed, the behavior can no longer be reproduced?

            The point of a reduced test script is to identify what is causing the behavior. If the script is not reduced, how can you know which code is causing the behavior?

            I cannot make any advisement on how to improve the performance as there is too much code here to consider, and I feel all of this code is not what is causing the behavior. There is likely a specific action, such as the linq or a loop that is causing the behavior.

            As I cannot debug or reduce the script on your behalf, you can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
            Last edited by NinjaTrader_ChelseaB; 09-14-2022, 10:44 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by elirion, Today, 01:36 AM
            0 responses
            1 view
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            2 views
            0 likes
            Last Post gentlebenthebear  
            Started by samish18, Yesterday, 08:31 AM
            2 responses
            9 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by Mestor, 03-10-2023, 01:50 AM
            16 responses
            389 views
            0 likes
            Last Post z.franck  
            Started by rtwave, 04-12-2024, 09:30 AM
            4 responses
            31 views
            0 likes
            Last Post rtwave
            by rtwave
             
            Working...
            X