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 JoMoon2024, Today, 06:56 AM
            0 responses
            6 views
            0 likes
            Last Post JoMoon2024  
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            17 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            5 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,786 views
            0 likes
            Last Post Leafcutter  
            Started by poplagelu, Today, 05:00 AM
            0 responses
            3 views
            0 likes
            Last Post poplagelu  
            Working...
            X