Go Back   NinjaTrader Support Forum > NinjaTrader 7 > General Development

General Development General NinjaScript development questions.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 03-12-2018, 01:01 PM   #1
TazoTodua
Senior Member
 
Join Date: Sep 2016
Posts: 349
Thanks: 243
Thanked 5 times in 5 posts
Default 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 TazoTodua; 03-12-2018 at 01:04 PM.
TazoTodua is offline  
Reply With Quote
Old 03-12-2018, 01:32 PM   #2
NinjaTrader_Jim
NinjaTrader Customer Service
 
NinjaTrader_Jim's Avatar
 
Join Date: Nov 2016
Location: Denver, CO
Posts: 1,661
Thanks: 90
Thanked 442 times in 419 posts
Default

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
File Type: zip IndicatorInIndicator.zip (3.5 KB, 6 views)
NinjaTrader_Jim is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Jim for this post:
Old 03-12-2018, 01:46 PM   #3
TazoTodua
Senior Member
 
Join Date: Sep 2016
Posts: 349
Thanks: 243
Thanked 5 times in 5 posts
Default

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.
TazoTodua is offline  
Reply With Quote
Old 03-12-2018, 02:20 PM   #4
NinjaTrader_Jim
NinjaTrader Customer Service
 
NinjaTrader_Jim's Avatar
 
Join Date: Nov 2016
Location: Denver, CO
Posts: 1,661
Thanks: 90
Thanked 442 times in 419 posts
Default

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.
NinjaTrader_Jim is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Jim for this post:
Old 03-12-2018, 02:36 PM   #5
TazoTodua
Senior Member
 
Join Date: Sep 2016
Posts: 349
Thanks: 243
Thanked 5 times in 5 posts
Default

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.
TazoTodua is offline  
Reply With Quote
Old 03-12-2018, 03:34 PM   #6
NinjaTrader_Jim
NinjaTrader Customer Service
 
NinjaTrader_Jim's Avatar
 
Join Date: Nov 2016
Location: Denver, CO
Posts: 1,661
Thanks: 90
Thanked 442 times in 419 posts
Default

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.
NinjaTrader_Jim is offline  
Reply With Quote
Old 03-14-2018, 08:56 AM   #7
koganam
Senior Member
 
Join Date: Feb 2008
Location: omegasigmaindicators.com
Posts: 7,198
Thanks: 56
Thanked 2,998 times in 2,425 posts
Default

Quote:
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.
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add indicator inside indicator ninjatrader 8 mdanial6 Platform Technical Support 10 03-21-2018 07:14 AM
Add-on Properties Window Approach Rudmax Add-On Development 2 01-31-2018 03:16 PM
Can fast approach of Draw.Region() be used when indicator in hosted in strategy? fx.practic Strategy Development 5 08-09-2017 02:44 PM
Executing a Ninjatrader 8 indicator via an Add-On mlange Version 8 Beta 2 05-16-2016 06:01 PM
Trying to add input series to indicator after indicator creation risingfire Strategy Development 4 05-31-2014 05:30 PM


All times are GMT -6. The time now is 05:02 PM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.