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 Tim-c, Today, 03:54 AM
    0 responses
    3 views
    0 likes
    Last Post Tim-c
    by Tim-c
     
    Started by FrancisMorro, Today, 03:24 AM
    0 responses
    2 views
    0 likes
    Last Post FrancisMorro  
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,771 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    31 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    945 views
    0 likes
    Last Post spwizard  
    Working...
    X