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

Combine indicator in strategy

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

    Combine indicator in strategy

    Indicator has the following using statement
    using NinjaTrader.NinjaScript;

    Strategy has the following statements
    using NinjaTrader.NinjaScript;
    using NinjaTrader.NinjaScript.Indicators;​


    Can I infer from this that I could embed the indicator inside my strategy attached is a base strategy with a base indicator
    Attached Files

    #2
    Yes, you can embed an indicator inside your strategy. See for instance in the help: https://ninjatrader.com/support/help..._strategie.htm.

    Use AddChartIndicator https://ninjatrader.com/support/help...tindicator.htm to add the nested indicator visually to the chart the strategy is running on.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Thanks, I do that all over the place. My question relates to another post from today
      Object loosing reference after reload strategy - please load the attached test indicator (MyTestIndicator.cs) to a chart, then add/enable the test strategy (MyTestStrategy.cs). It all works without an error - so far so good. Then please see the attached video (gif) - I simply do a change in a print code line and recompile


      The thought is both the indicator and strategy are reloaded and thereby kept in sync.

      Comment


        #4
        I have commented on the other thread. From what I can tell there is no issue here. You just need to F5 the chart after you recompile.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Hello BartMan,

          You actually cannot do what your sample shows due to how the indicator cache works.

          Your script is missing the indicator generated code at the bottom of the file, that generated code is what gives your strategy access to the indicator. While your sample will compile now it would not if you tried to call your indicator to get a value or update it.

          Indicators are placed inside the indicators sub folder because the platform has special logic that runs during a compile of your indicator that generates those constructors in the NinjaScript generated code at the bottom of the file. That code gives strategies, market analyzer columns and indicators access to your indicator.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Thx Jessie/Bruce. The indicator is now set to call the order method in my strategy.

            The Addon is the controller it keeps my "instructions" I have multiple instances of the indicator and strategy
            The indicator handles reading/recording/ the data, as well as "noticing events"
            The strategy handles the orders.

            Last edited by BartMan; 05-09-2023, 09:24 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by flonkle, Today, 01:19 AM
            4 responses
            28 views
            0 likes
            Last Post flonkle
            by flonkle
             
            Started by sofortune, 06-13-2024, 02:31 AM
            2 responses
            19 views
            0 likes
            Last Post sofortune  
            Started by GodAtum, Today, 09:52 AM
            10 responses
            21 views
            0 likes
            Last Post GodAtum
            by GodAtum
             
            Started by WHICKED, 06-27-2023, 12:07 PM
            83 responses
            864 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by Rxxar, Today, 09:56 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X