Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code efficiency question

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

    Code efficiency question

    If a complicated indicator is called from a number of strategies, would there be any positive or negative if that logic is imbedded directly into each strategy rather than calling it?

    #2
    Hi Rod, would you call the same indicator method on the same instrument / timeframe and with exactly the same parameters?

    Comment


      #3
      Same timeframe, same parameters, different instrument, but called multiple times in each strategy
      Last edited by RodS7; 09-25-2012, 06:38 AM.

      Comment


        #4
        Thanks Rod, then you would not be accessing a cached instance with your call, so I would not expect to see any harm on performance if you directly embed as method for example.

        Comment


          #5
          I tested 1 startegy that called indicator that called another indicator.
          Strategy with imbedded both indicators calculations was 2.5 times faster.
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment


            #6
            fx.practic

            now that's definitive! Thanx

            I am curious how you measured the speed....

            Rod

            Comment


              #7
              Well, the methodology.

              1) Write 3 strategies (attached):
              sCodeEfficiencyTestSmaExternal - calls SMA(200)
              sCodeEfficiencyTestSmaImbeddedFast - calculates internaly only current value of SMA(200)
              sCodeEfficiencyTestSmaImbeddedSlow - calculates internaly value of SMA(200) ant put it to internal DataSeries

              2) Load CL minute chart from 01.01.2012 to 26.09.2012.

              3) Disconnect NT from quotes provider.

              4) Disconnect internet and close almost all programs, exept NT and notepad.

              5) Run optimisation of each strategy (see screenshot):
              chart: CL 1 mint from 01.01.2012 to 26.09.2012
              optimize: variable Iteration from 1 to 1000, step 1

              6) measure the time of each optimization by CASIO W-S200

              Results:
              3 minutes 08 seconds - sCodeEfficiencyTestSmaExternal
              1 minutes 35 seconds - sCodeEfficiencyTestSmaImbeddedFast
              6 minutes 11 seconds - sCodeEfficiencyTestSmaImbeddedSlow
              Attached Files
              Last edited by fx.practic; 09-26-2012, 03:08 AM.
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment

              Latest Posts

              Collapse

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