Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Call the exact instance of indicator that is on the chart

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

    Call the exact instance of indicator that is on the chart

    Hi,

    in my effort to reuse code and save cpu resources because OnRender can only render on one price panel, and it would therefore be better to use the cache from the original main indicator, it seems best to write an indicator that uses the cache from the indicator that is already on the chart. Therefore I would either need to use this indicator always with the exact same settings or would have to change the code everytime I want another setting.
    Therefore I am looking for a way to call the exact instance of indicator that is already on the chart.
    Jesse said it might be possible with a delegate but after reading about delegates, I believe I would still need to know the parameters in order that the indicator doesn't get cached a second time.

    How can I get the parameters of an indicator that is on the chart and call with them this already cached instance?

    I am doing a C# course to get the hang of it but so far I am still not sure how to do it.


    Greetings

    #2
    Hello seykool,

    I am not certain I understand what you are saying about delegates, that is not something I had previously suggested.

    How can I get the parameters of an indicator that is on the chart and call with them this already cached instance?
    Could you provide a more specific example of what problem you face? From your description I am not sure how to advise you. Worrying about the cache is generally not going to be a concern and is just a extra item that the platform has for internal performance optimization. If you are doing something which is very performance heavy for rendering then the cache is not going to help.

    Comment


      #3
      Hello Jesse,

      I appreciate your help.
      With all my tick indicators on several charts, resource saving got almost most important because if it all lags like crazy, the best indicator isn't worth anything. And I have my CPU already overclocked to 4.1Ghz.

      I have an indicator with a logic that calculates all data for 3 chart windows. I can't make 3 indicators from it because the logic has to calculate it anyways. Thus the idea to write an extension that calls the main indicator for getting the data to render on the second and third panel.

      If you call an indicator with the exact same parameters twice, it only calculates and caches it once. (referencing this thread: https://ninjatrader.com/support/foru...or#post1187596 ).
      Since I don't want to change the code of the extension indicator everything I change a setting, the extension indicator shall find the instance of the main indicator with it's parameters that is already on the chart. Then it shall call this instance to get the data to plot from it.

      With ChartPanel.Index I can find the main indicator but I am not sure how to get the parameters.
      Right, you actually didn't said to use a delegate, you said "add a user input to delegate logic based on which input value was selected". Would I get the parameters this way? I am not sure how to do this.
      Couldn't I make the main indicator static? Then it can't get cached a second time and I wouldn't have to instantiate it with the exact parameters.

      Greetings,
      Seykool
      Last edited by seykool; 01-30-2022, 01:50 PM.

      Comment


        #4
        Hello seykool,

        Unfortunately I cannot understand the use case as described. If you need the same parameters you would apply the indicator twice using the same parameters and that would utilize any optimization features like the cache. If you need to make one indicator dependent on another you would need to call it in code and supply the parameters you wanted when calling the indicator.


        Please let me know if I may be of additional help.

        Comment

        Latest Posts

        Collapse

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