• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicators cache

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

    Indicators cache

    Hello

    Please explain how indicators cache works.
    E.g.

    Code:
            
        public partial class Indicator : IndicatorBase
        {
              private MyHeavyIndicator[] cacheMyHeavyIndicator = null;
    I have very heavy custom indicator, based on other custom one. I need to cache the last one. I suppose cacheMyHeavyIndicator array is for caching indicator inside current instance. Right?
    I need global cache for all instances. I think code would be as below

    Code:
            
        public partial class Indicator : IndicatorBase
        {
              private static MyHeavyIndicator[] cacheMyHeavyIndicator = null;
    Last edited by ren37; 01-21-2016, 03:51 PM.

    #2
    I'm trying static cache.
    Now I got error message Error on calling 'OnBarUpdate' method for indicator ... Index out of range
    I should addmit that I commented this cause EqualsInput() is always false even for identical data series.
    I need some advice on this.

    Code:
    //cachemzOrderFlow[idx].EqualsInput(input)
    So I think I need some processing of indicator unloading and deleting it from global static cache.
    Something like that

    Code:
            // Parent indicator
            protected override void OnTermination()
            {
                if (cachemzOrderFlow != null)
                    for (int idx = 0; idx < cachemzOrderFlow.Length; idx++)
                           if (cachemzOrderFlow[idx] == OrderFlowInstance) cachemzOrderFlow[idx].RefCount--;
    ...
            
            // Child indicator mzOrderFlow
            protected override void OnTermination()
            {
    
                foreach (mzOrderFlow i in cachemzOrderFlow)             
                     if (i.RefCount == 0) 
                        cachemzOrderFlow = cachemzOrderFlow.Where(val => val != i).ToArray();
    ...
    What do you think?

    Comment


      #3
      Hello,

      Thank you for the question.

      I wanted to ask, is there a problem in the current usage you are using where the indicator is not being cached?

      Could you provide a simple example of the structure you are using that is not working? In general the NinjaScript generated code should be generated automatically but depending on the structure of your code this could be affected.

      I am unsure by the information provided on what the end goal is for this question, could you provide further details on what is or is not working along with what the goal is for your question?

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Hello

        I do my project in Visual Studio
        I have one base indicator mzOrderFlow and a few others.
        mzOrderFlow provides low level data series to other my indicators.
        E.g. on this chart I use mzBestBidAsk indicator 3 times in different modes.
        Each mzBestBidAsk uses two instances of mzOrderFlow to get parsed orderflow and level 1 input.
        So I got 7 mzOrderFlow indicators instances if not cached on this chart.
        With cache I could have only 4.

        Comment


          #5
          Hello,

          Thank you for the reply.

          Based on the image I do see the indicators that are visible are using different settings so by default they should not be cached as they are different instances. Only exactly identical instances should be cached as that would really be the only case where caching could be used because they are identical.

          I.E. if you used two SMA(12) in the script, in this case there is no change between the call to SMA so it could be cached.

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            I use identical instances of mzOrderFlow indicator called from different instances of mzBestBidAsk indicator.
            Ofcourse I do not create new mzOrderFlow instance every time i need tick data inside mzBestBidAsk, so default cache is useless in my case.

            I need share one instance of mzOrderFlow among three mzBestBidAsk indicators. And I am talking about global static cache.

            Comment


              #7
              Hello,

              Thank you for the reply.

              In general indicators are not designed to share one instance or have a global cache, the cache is mainly used only if you are using a identical instance of an indicator in the same script, in that case the same instance would be used. For what you are asking, likely you would need to design your own caching system outside of an indicator and completely avoid the built in caching for the main item you are referring to.

              One concept of this would be to use an addon and utilize static to allow the other indicators you use to use the core logic in the addon. This of course is a process we have no documentation or samples for as this would be your own custom addon that deals with your indicators.

              The main indicators logic would need to be moved into the addon and adjusted where needed to work in that situation, once this is completed you could in theory access this addon from the indicators as a single instance.

              For a global cache this would really be the only way I could see this working as the built in cache was not designed with what you are trying in mind.

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by sambo81, Yesterday, 06:57 PM
              1 response
              17 views
              0 likes
              Last Post NinjaTrader_ThomasC  
              Started by tgn55, Today, 08:34 AM
              0 responses
              3 views
              0 likes
              Last Post tgn55
              by tgn55
               
              Started by TazoTodua, Today, 06:00 AM
              0 responses
              8 views
              0 likes
              Last Post TazoTodua  
              Started by gbux11, Today, 02:36 AM
              0 responses
              8 views
              0 likes
              Last Post gbux11
              by gbux11
               
              Started by fx.practic, Today, 01:47 AM
              0 responses
              15 views
              0 likes
              Last Post fx.practic  
              Working...
              X