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

NinjaTrader Add indicator from indicator - another approach?

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

    NinjaTrader Add indicator from indicator - another approach?

    I was trying to find a solution for the mentioned problem, and I think I was near - in strategies, I've created a sample strategy:

    Code:
    namespace NinjaTrader.Strategy
    {
    	public class SBExample  : StrategyBase{
    		NinjaTrader.Indicator.IndicatorBase indi_ ;
    		private int panelN;
    
    		public void Add_(NinjaTrader.Indicator.IndicatorBase indi__ , int panel_ ){ 
    			indi_ = indi__;
    			panelN= panel_;
    		} 
    		protected override void Initialize()
                    {
                        Add(indi_);
    		    indi_.Panel = panelN;
                    }
    	}
    }

    the I create a simple indicator:

    Code:
    namespace NinjaTrader.Indicator
    {
        [Description("Enter the description of your new custom indicator here")]
        public class sample : Indicator
        {
            protected override void Initialize()
            {
    			NinjaTrader.Strategy.SBExample  sb= new NinjaTrader.Strategy.SBExample();
    			sb.Add_(EMA(20), 1); 
    			sb.SetUp();
            }
            protected override void OnBarUpdate() {  }
        }
    }

    When I add "sample indicator" on chart, it compiles well, but on chart, the "EMA" indicator is not being shown. I think I am near to achieve goal? what you think?
    Last edited by ttodua; 03-12-2018, 01:04 PM.

    #2
    Hello TazoTodua,

    Thanks for your inquiry.

    A hosting indicator will need to add its own Plots so the data can be viewed as a plot in the price panel or the indicator panel.

    I've attached a sample indicator demonstrating.

    I will also link to our example demonstrating how a strategy can manipulate an indicator for Strategy based plots in NT7.

    Plotting from a NinjaScript Strategy - https://ninjatrader.com/support/foru...ead.php?t=6651

    Please let me know if we can be of additional help.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Jim, thanks but you didnt quite catch what I wanted to achieve. The way you said, I know already. Instead, I was trying to avoid to again code plots. Because, let's say I am adding indicaot, which have different kind of plots, arrows and etc and etc... So, I wanted to use `Add()` exactly like it is done from `Strategy` (which you linked), why that cant be achieved from Indicators too? I think my code was somehow near to achieve the same.

      Comment


        #4
        Hello TazoTodua,

        Thanks for your additional question.

        To answer your question simply, Add() for adding an indicator is available through strategies, but is not available through indicators.

        In NT7, all we have available to display plots is the hosting indicator that contains the plots that we can write to. We cannot call Add() to add an indicator to an indicator, since this is only available for Strategies.

        Since we cannot use Add() to add an indicator within an indicator, any drawing objects will have to be implemented into the hosting indicator.

        Please let me know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          1) Jim, you are right what you say, but my main interest lies in, why INDICATORS cant do that? is there anything problem with code? i.e. is that functionality private to strategies, or why can the code I've given, cant be modified as it could achieve the goal?

          What programmatic problem is the barrier?

          thanks!

          2) btw, it's good if even for nt8 you would create feature request that Indicators could do that.

          Comment


            #6
            Hello TazoTodua,

            The Add() functionality is different between indicators and strategies. The functionality to add an indicator with Add() is simply unavailable in indicators when it is in strategies.

            NinjaTrader 8 uses "AddChartIndicator()" and the functionality is the same for being able to add an indicator to an indicator with this method vs. using this method to add the indicator to a chart. (We can use this method in strategies but not within indicators.) We do have a feature request tracking interest in this enhancement, and I will gladly submit a vote on your behalf.

            The ticket Id is SFT-2366.

            Please keep in mind, feature requests are fulfilled based on the development team's priorities and we cannot offer an ETA or promise of fulfillment. Upon implementation, the ticket ID's can be seen in the Release Notes page of the help guide.

            Release Notes: https://ninjatrader.com/support/help...ease_notes.htm

            If you have any additional questions, please let me know.
            JimNinjaTrader Customer Service

            Comment


              #7
              Originally posted by TazoTodua View Post
              1) Jim, you are right what you say, but my main interest lies in, why INDICATORS cant do that? is there anything problem with code? i.e. is that functionality private to strategies, or why can the code I've given, cant be modified as it could achieve the goal?

              What programmatic problem is the barrier?

              thanks!

              2) btw, it's good if even for nt8 you would create feature request that Indicators could do that.
              The programming problem is that the Add() method is not implemented, and so not available for use with Indicators.

              Of course, you can always write your own method to implement such functionality, but you would probably have to know internal details that are unavailable from NT, as it is a closed source tree.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Radano, 06-10-2021, 01:40 AM
              19 responses
              606 views
              0 likes
              Last Post Radano
              by Radano
               
              Started by KenneGaray, Today, 03:48 AM
              0 responses
              4 views
              0 likes
              Last Post KenneGaray  
              Started by thanajo, 05-04-2021, 02:11 AM
              4 responses
              470 views
              0 likes
              Last Post tradingnasdaqprueba  
              Started by aa731, Today, 02:54 AM
              0 responses
              5 views
              0 likes
              Last Post aa731
              by aa731
               
              Started by Christopher_R, Today, 12:29 AM
              0 responses
              11 views
              0 likes
              Last Post Christopher_R  
              Working...
              X