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

indicator reading another indicator

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

    #16
    Hi Jesse,

    actually this doesn't work at all! Because this would mean that the logic for both price panels have to be in one indicator but since the indicator is cached only once, it always runs only one of the two logics, specifically in OnCalculateMinMax, in OnRender it somehow gets it.
    Therefore the easiest will be to write a second indicator that extends the first. Since the first has tons of parameters and properties, it would be really ugly to always change the code when you want another color for e.g. There must be a way to select the indicator in reference. I saw indicators that allow you to do so. How could I do that?

    Greetings

    Comment


      #17
      Hello ,seykool

      If needed you could use two indicators, you could alternatively use one indicator and just add a user input to delegate logic based on which input value was selected. A single indicator being applied twice would be the best suggestion, if it needs to work differently between price panel and the lower panel logically you would need to add code to determine that and switch the logic used. OnRender will otherwise adjust to the panel the indicator is in, if you are having trouble with something being incorrect when changing from price panel to sub panel you would need to work that out in your logic/calculations.



      JesseNinjaTrader Customer Service

      Comment


        #18
        Originally posted by NinjaTrader_Jesse View Post
        2. I would not suggest trying to over complicate the series being exposed, generally exposing a Series<double> is the best way/most efficient. If you expose a class and instantiate an object for each slot that would take a more resources than a simple type like a double.
        Could you clarify what you mean exactly?

        Let's say I have a class:
        class myClass()
        {
        Int myInt;
        string myString;
        double myDouble;
        }
        Which I use as datatype for a List, and then call this list from another indicator by instantiating an object of the indicator that contains the class.
        Do you mean this would be more resource intensive than having 3 series of int, string, and double, and calling them the same way?

        Thanks
        Last edited by seykool; 01-31-2022, 04:56 AM.

        Comment


          #19
          Originally posted by NinjaTrader_Jesse View Post
          Hello ,seykool
          If needed you could use two indicators, you could alternatively use one indicator and just add a user input to delegate logic based on which input value was selected. A single indicator being applied twice would be the best suggestion, if it needs to work differently between price panel and the lower panel logically you would need to add code to determine that and switch the logic used. OnRender will otherwise adjust to the panel the indicator is in, if you are having trouble with something being incorrect when changing from price panel to sub panel you would need to work that out in your logic/calculations.
          I tried to have it in one indicator that has two logics for two price panels. After I figured out the logic, it turned out that it nevertheless calculates and caches the indicator twice, although both have the exact same settings!

          I added this to OnBarUpdate:
          onBar: 1006 onTick: 18 onPanel: 0
          onBar: 1006 onTick: 18 onPanel: 1
          ( Print("onBar: " + CurrentBar + " onTick: " + Bars.TickCount + " onPanel: " + ChartPanel.PanelIndex.ToString()); )

          You said it shouldn't do that, what could cause this? I mean, both indicators on panel 0 and 1 have the exact same parameters (apart from the price panel) and they are the same indicator.


          Greetings

          Comment


            #20
            Hello seykool,

            Do you mean this would be more resource intensive than having 3 series of int, string, and double, and calling them the same way?
            The more objects you create the more resources would be used. If you create many instances of your class that is more resource use than just a series of a basic type like int. You can use the NinjaScript monitor to review how much resources a specific part of your code uses, our support cannot guess at what would be more efficient. You can test using a series vs not using a series if you wanted to know the specific outcome.

            I tried to have it in one indicator that has two logics for two price panels. After I figured out the logic, it turned out that it nevertheless calculates and caches the indicator twice, although both have the exact same settings!
            The cache is a very simple mechanism built into the platform to cache general data for the indicator, its not a catch all for a slow script and will not help with general processing. If your script takes a lot of resources while processing and you need to apply it twice its just going to take twice as much resources. If that is too much for the target PC the only options would be to program a different script that uses less resources, don't apply it twice or use a more powerful pc.

            You said it shouldn't do that, what could cause this? I mean, both indicators on panel 0 and 1 have the exact same parameters (apart from the price panel) and they are the same indicator.
            Again if you are relying on the cache to allow the script to work you have a greater problem there, the cache should not be relied on as a part of the development cycle. That is a part of NinjaScript which can potentially help with performance for loading series data in advanced use cases but if the script in question is doing something demanding you will still see a lot of usage the more instances you add.

            If you need to make the script as efficient as possible it should run as a single instance on the chart and then you can fine tune your logic to be as efficient as needed for the given use case.



            JesseNinjaTrader Customer Service

            Comment


              #21
              The hint with the Resource Monitor is brilliant, thanks.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by lightsun47, Today, 03:51 PM
              0 responses
              4 views
              0 likes
              Last Post lightsun47  
              Started by 00nevest, Today, 02:27 PM
              1 response
              8 views
              0 likes
              Last Post 00nevest  
              Started by futtrader, 04-21-2024, 01:50 AM
              4 responses
              44 views
              0 likes
              Last Post futtrader  
              Started by Option Whisperer, Today, 09:55 AM
              1 response
              13 views
              0 likes
              Last Post bltdavid  
              Started by port119, Today, 02:43 PM
              0 responses
              8 views
              0 likes
              Last Post port119
              by port119
               
              Working...
              X