Go Back   NinjaTrader Support Forum > NinjaTrader 7 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 03-20-2017, 08:01 AM   #1
Titus
Member
 
Join Date: Dec 2014
Posts: 38
Thanks: 0
Thanked 5 times in 4 posts
Default Indicator in two panels

Is it possible to create an indicator that uses two panels, one of them being the price panel? How do I specify the target panel for each plot and drawing object (like arrows and triangles)?
What I am trying to do is have the indicator draw on the price panel (like a MA), and have a STO like other panel. I could split it into two indicators, but they share a lot of calculation that I do not want to duplicate (for the sake of efficiency and speed).
So, is it doable in NT7? What about NT8?
Titus is offline  
Reply With Quote
Old 03-20-2017, 12:35 PM   #2
NinjaTrader_Jim
NinjaTrader Customer Service
 
NinjaTrader_Jim's Avatar
 
Join Date: Nov 2016
Location: Denver, CO
Posts: 252
Thanks: 6
Thanked 54 times in 53 posts
Default

Hello Titus,

Thanks for writing in.

Some users have reported that using the DrawOnPricePanel within OnBarUpdate() has allowed them to do this, but it is not the recommended solution.

It is instead advised to create 2 separate indicators. One that plots to the Price Panel and one that draws to the indicator panel.

It is possible to have a strategy place the indicators in a specified panel, but this is possible because the added indicators are managed by the strategy. Adding indicators to a chart would not have any reference of what other indicators exist on the chart and what panels exist.

You may wish to reference the documentation and reference sample below:

DrawOnPricePanel NinjaTrader 7: https://ninjatrader.com/support/help...pricepanel.htm

DrawOnPricePanel NinjaTrader 8: https://ninjatrader.com/support/help...pricepanel.htm

Plotting within a NinjaScript Strategy: http://ninjatrader.com/support/forum...ead.php?t=6651

Additionally, there is a Plot() override that you may wish to use to place drawing objects where ever you may like them. This method falls outside of our documentation. As such, there is only a certain amount of support we may provide in this direction. There is a sample that outlines this provided with NinjaTrader 7 in the folder \Documents\NinjaTrader 7\bin\Custom\Indicator\CustomPlotSample.cs

Please let me know if I may be of further assistance.
NinjaTrader_Jim is offline  
Reply With Quote
Old 03-20-2017, 01:17 PM   #3
Titus
Member
 
Join Date: Dec 2014
Posts: 38
Thanks: 0
Thanked 5 times in 4 posts
Default

Thank you Jim for your response.

I think splitting the indicator is the way to go then. But that raises another question.
Let's say I split the indicator into indicators IndA and IndB. Is there a way to guarantee that IndA is calculated first and then somehow IndB can access some of the results that IndA has already calculated (so it does not have to be done again), and use it for further calculations?
Titus is offline  
Reply With Quote
Old 03-20-2017, 01:42 PM   #4
NinjaTrader_Jim
NinjaTrader Customer Service
 
NinjaTrader_Jim's Avatar
 
Join Date: Nov 2016
Location: Denver, CO
Posts: 252
Thanks: 6
Thanked 54 times in 53 posts
Default

Hello Titus,

Thanks for getting back to me.

There is a reference sample that may be of use to you for creating indicators that can reference data from one another. You may try a similar approach to see how much of your code you can re-use.

Exposing indicator values that are not plots: http://ninjatrader.com/support/forum...ead.php?t=4991

Alternately, but not necessarily recommended, you may try to write to a global space. This falls outside the scope for NinjaScript support, but you are welcome to apply any C# techniques you have at your disposal to your indicators and strategies.

For NinjaTrader 7, this is very easy. We provide the files (My) Documents\NinjaTrader 7\bin\Custom\Indicator\UserDefinedMethods.cs and (My) Documents\NinjaTrader 7\bin\Custom\Strategy\UserDefinedMethods.cs . You can store global variables that will be included for all Indicators in this file. Make sure they are part of the Indicator class. For example,
Code:
    partial class Indicator
    {
        /// <summary>all the plots from all the indicators</summary>
        public static Plot[][] allThePlots;
    }
NinjaTrader 8 will not have a similar file. I am including a publicly available link from the MSDN C# documentation which will guide you toward putting together a global scope file in NT8.

https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

Whichever way you choose, you will want to add some logic surrounding your global objects.

Please let us know if we may be of further assistance.
NinjaTrader_Jim is offline  
Reply With Quote
Old 03-20-2017, 02:09 PM   #5
Titus
Member
 
Join Date: Dec 2014
Posts: 38
Thanks: 0
Thanked 5 times in 4 posts
Default

Thank you again, I'll dig into it and see what I can do.
Titus is offline  
Reply With Quote
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 know the number of Panels in an indicator freewind General Development 1 10-08-2010 05:08 AM
Indicator panels billitin Suggestions And Feedback 1 12-21-2008 03:52 PM
one indicator - mulitple panels ATI user Indicator Development 3 06-30-2008 12:24 PM


All times are GMT -6. The time now is 09:37 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. Visit the CFTC resources for education regarding the industry and signs of fraud.