Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Load an indicator only when another indicator is loaded

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

    Load an indicator only when another indicator is loaded

    Hi,
    I have 2 separate indicator. From the second one I have to read a draw object collection that creates the first one. Sometimes, when I refresh the indicators on the chart, the draw objects collection is not ready to be read from the second indicator so I need to refresh multiple times.
    Can you give me a method to load and active the second indicator on the chart only if the first one is completely loaded?

    Thanks

    #2
    Hello, thanks for writing in. There is no way to wait for a separate indicator to load. The only way that may work to resolve this is to use a Strategy that does not submit any orders, but only takes advantage of the AddChartIndicator() method. This way you can call AddChartIndicator() first for the indicator that supplies the draw objects, then call it again for the indicator that uses the draw objects. Alternatively, you would need to unify the two indicators into one indicator.

    We have an example of using AddChartIndicator() here:

    Comment


      #3
      Hi,
      I tried without any result. I obtain the error: object not set on an instance of object.
      Attacched all my indicators and strategies and i want to run first "session definition" and last "DeltaCalculation".

      Can you help me?

      Thanks
      Attached Files

      Comment


        #4
        Hi, you need to initialize your indicators before passing them into AddChartIndicator. See the "SampleMaCrossover" strategy for an example of how to do this.

        Comment


          #5
          I obtain that:
          Click image for larger version

Name:	image.png
Views:	151
Size:	70.0 KB
ID:	1258450

          Comment


            #6
            Hi, you do not have the syntax correct. The "SessionDefinition" and "DeltaCalculation" are the type names. You need to use a different name for these. Since C# is case sensitive, you can just make the first letter in each variable name lower case:

            Code:
            private NinjaTrader.NinjaScript.Indicators.CustomIndicators.SessionDefinition sessionDefinition;
            private NinjaTrader.NinjaScript.Indicators.CustomIndicators.DeltaCalculation deltaCalculation;
            ...
            sessionDefinition = NinjaTrader.NinjaScript.Indicators.CustomIndicators.SessionDefinition();
            deltaCalculation = NinjaTrader.NinjaScript.Indicators.CustomIndicators.DeltaCalculation();​

            Comment


              #7
              Ok, but same error:
              Click image for larger version

Name:	image.png
Views:	151
Size:	44.4 KB
ID:	1258461

              Comment


                #8
                Hi, I am not sure about the transalation of this compile error to English. Possibly you need to pass in parameters into these indicators. Check the parameter list that comes up when you type '(' as in

                Code:
                sessionDefinition = NinjaTrader.NinjaScript.Indicators.CustomIndicators.SessionDefinition[B](  <- see what comes up after typing this[/B]

                Comment


                  #9
                  I don't think the indicator parameters match the definition.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #10
                    Hi,
                    I have no parameters to pass. Anything happened.

                    Thanks

                    Comment


                      #11
                      Hi, Its not liking the type name that you are using here. The only other possibility is that "SessionDefinition" and "DeltaCalculation" are not indicator types.

                      Comment

                      Latest Posts

                      Collapse

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