Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Computational Efficiency Question: External or Internal Methods?

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

    Computational Efficiency Question: External or Internal Methods?

    Howdy--

    I have a number of methods that I use within my base strategy (i.e., GoLong, GoShort, ATM, Reporting, etc) that I heretofore have just cut and paste into a new strategy (and then bracketed with Regions). However, I got to thinking about creating external indicators that I could pass parameters to in exchange for processed outcomes or results. However, that got me thinking about computational efficiency, which led me to these questions:

    1. Is it more computationally efficient to call and access "method" language within a strategy or to call and access "indicator" language from an external call?

    2. What is the most computationally efficient way to structure my strategy tasks (i.e., internal methods or external indicators)?

    3. What are the memory impacts of each approach?

    4. What question(s) am I not asking that I should be concerning computational efficiency?

    I'm just looking to understand the foundational reasons for having my code be as efficient as possible.

    Thanks for your help,

    Aventeren

    #2
    Hi aventeren,

    1) It would be more efficient to have a method in your strategy that does calculations instead of an indicator that is called. This is so that the indicator instance does not have to be loaded into memory, the data series does not have to be copied, added to memory and passed to the indicator, and the calculations will not have to be done and cached for every bar of historical data.

    However, having the calculations in an indicator can be nice because you can call it from any script, and you would also be able to add it to a chart and see your calculations visually.

    2 & 3) See above

    4) There can be better ways of being efficient with any C# code, however, I would need to know what you are trying to do to see if there is a more efficient way as this is a really open ended question. (Most of the time a strategies are simple enough and do not use a lot of loops and are already as efficient as they are going to get).
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    575 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X