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

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 elirion, Today, 09:32 PM
    0 responses
    2 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by cre8able, Today, 09:15 PM
    1 response
    5 views
    0 likes
    Last Post bltdavid  
    Started by cummish, Today, 08:43 PM
    0 responses
    12 views
    0 likes
    Last Post cummish
    by cummish
     
    Started by Option Whisperer, Today, 07:58 PM
    4 responses
    21 views
    0 likes
    Last Post Option Whisperer  
    Started by ETFVoyageur, 05-07-2024, 07:05 PM
    13 responses
    87 views
    0 likes
    Last Post ETFVoyageur  
    Working...
    X