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

Performance query

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

    Performance query

    Hi,

    I've a few indicators that use other functions (or indicators), in the following manner

    for example

    temp = SMA(Volumes[0], 50)[0];

    This might be called quite often (on price change for example).

    I also have coded in some of the indicators, in a different way

    for example, in declarations

    private SMA SMA1;
    SMA1 = SMA(Volumes[0], 50);

    The access is via

    SMA1[0];

    So, my general query is, and basically just looking for your opinion, which is the most efficient to use, if being called regularly?

    My thoughts were that the first results in the whole SMA calculation and series being evaluated each time. The second keeps it up to date on the fly, but at the cost of keeping the series in memory?

    Is there a difference?
    Which method would you recommend?

    Thanks!

    #2
    Hello pjsmith,

    Thanks for your inquiry.

    If you are calling the indicator multiple times, it would be a best practice to store a reference to that instance of an indicator rather than calling the indicator method multiple times.

    This is outlined in the NinjaScript Best Practices page of the help guide. I'll provide a link to this publicly available resource below.

    NinjaScript Best Practices (Performance) - https://ninjatrader.com/support/help...tm#Performance

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    1 view
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    238 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    383 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    1 view
    0 likes
    Last Post oviejo
    by oviejo
     
    Started by pechtri, 06-22-2023, 02:31 AM
    10 responses
    125 views
    0 likes
    Last Post Leeroy_Jenkins  
    Working...
    X