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

Indicators decreasing strategy quickness

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

    Indicators decreasing strategy quickness

    Hi,

    I have about 14 custom indicators within my strategy.
    All of which are being instantiated within the State == State.DataLoaded block.

    And they are slowing down my strategy even when I am returning at the very start of every OnBarUpdate .

    My Strategy is running OnPriceChange calculation.

    Any advice on better ways to use less CPU when using this many indicators? Each indicator pretty much needs to know what happened in the last N number of bars too. Some Indicators only need to be ran once per day or once per 60 mins which I do account for when I am actually using the values returned from the indicator. But like I said, even if I am doing nothing in the OnBarUpdate, it still slows down the strategy.

    I'm talking about running the strategy on historical data by the way. Literally just one day of historical data but it takes about 5-10mins just to run through 4 hours of historical data on a 20 range bar (during the euro session too).

    Any advice?

    Cheers,

    Tarik

    #2
    Hi Tarik, thanks for posting. The indicators hosted by the OnPriceChange strategy will also run OnPriceChange. Even when you return from OnBarUpdate these indicators are still calling their OnBarUpdate method. One test would be to load a chart with Load Data Based On: Bars, load 10 bars, and see what the performance is like there. If you are not using Tick Replay, historical calculations take place OnBarClose anyway, so the indicators being used are taking CPU time by nature/the way they are coded. You can also ignore the historical data altogether using this statement at the top of OnBarUpdate:
    Code:
    if(State == State.Historical)
        return;
    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hey Chris thanks for your reply.

      I understand this is the nature of using indicators but I was just wondering if it may be beneficial to instantiate the indicators in another way so they don't have to run on every OnBarUpdate (on price change). because I only need a select few once per day I could just instantiate that indicator once within a function and call it only once rather than have it be instantiated in the State == State.DataLoaded which means like you said it'll run on every OnPriceChange. If that makes sense?

      But to be honest I'm probably answering my own question and I think I can do it this way as long as the indicator is coded correctly to only work once per day.

      I'll give Load Data Based On: Bars too to see if I can play around with things and measure the speed every time I change something.

      Thanks,

      Tarik

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by TradeForge, 04-19-2024, 02:09 AM
      2 responses
      28 views
      0 likes
      Last Post TradeForge  
      Started by aprilfool, 12-03-2022, 03:01 PM
      3 responses
      327 views
      0 likes
      Last Post NinjaTrader_Adrian  
      Started by giulyko00, Today, 12:03 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by f.saeidi, Today, 12:14 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by AnnBarnes, Today, 12:17 PM
      1 response
      2 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Working...
      X