Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 02-17-2017, 10:24 AM   #1
JBU1314
Member
 
Join Date: Jul 2015
Posts: 64
Thanks: 17
Thanked 1 time in 1 post
Default Draw 2nd Data Series on Panel 2

Hi All,
I am trying to get the second data series onto Panel 2 but have difficulties to implement it.
Attached a picture to clarify. Any advice what I missed?
I basically only want the 50 Period of the SPY on the chart on the second panel which currently shows as AAPL. Here my code.

else if (State == State.Configure)
{
AddDataSeries("SPY", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);

_smaSPY = SMA(Closes[1], 50);
_smaSPY.Plots[0].Width = 2;
_smaSPY.Plots[0].Brush =Brushes.Purple;
_smaSPY.Panel = 3;
base.AddChartIndicator(_smaSPY);
Attached Images
File Type: jpg PicNT.JPG (89.6 KB, 7 views)
JBU1314 is offline  
Reply With Quote
Old 02-17-2017, 11:09 AM   #2
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,422
Thanks: 206
Thanked 522 times in 509 posts
Default

Hello JBU1314, and thank you for your question. You will need to set your indicator or strategy's DrawOnPricePanel setting to true during State.SetDefaults. Please let us know if there are any other ways we can help.
NinjaTrader_JessicaP is offline  
Reply With Quote
Old 02-17-2017, 11:21 AM   #3
JBU1314
Member
 
Join Date: Jul 2015
Posts: 64
Thanks: 17
Thanked 1 time in 1 post
Default

Hi Jessica,
I did that but I still dont have SPY displayed on Panel 2 jsut the apple as shown in the screen shot attached.
JBU1314 is offline  
Reply With Quote
Old 02-17-2017, 12:48 PM   #4
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,422
Thanks: 206
Thanked 522 times in 509 posts
Default

I misunderstood your intent. In order to do this we have to make a copy of the SMA indicator and override its PanelUI member. I have provided an example.
Attached Files
File Type: cs SMAPanel2.cs (4.1 KB, 7 views)
File Type: cs Example1663081.cs (2.4 KB, 15 views)
NinjaTrader_JessicaP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_JessicaP for this post:
Old 02-17-2017, 03:51 PM   #5
JBU1314
Member
 
Join Date: Jul 2015
Posts: 64
Thanks: 17
Thanked 1 time in 1 post
Default

This is great information. Thank you very much!
JBU1314 is offline  
Reply With Quote
Old 02-17-2017, 04:12 PM   #6
JBU1314
Member
 
Join Date: Jul 2015
Posts: 64
Thanks: 17
Thanked 1 time in 1 post
Default

The problem is only that The SMAPanel2 is still showing the primary series (in this example APPL) instead of the SPY which is he secondary Dataseries. So I still do have the same problem. What did i miss?
Attached Images
File Type: jpg Capture3.JPG (137.3 KB, 5 views)
JBU1314 is offline  
Reply With Quote
Old 02-20-2017, 08:02 AM   #7
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,422
Thanks: 206
Thanked 522 times in 509 posts
Default

If you would like your strategy to trade on your secondary data series, you can pass in your SPY series to your strategy as shown in the attached image.

Otherwise, if you would like your strategy to monitor AAPL and your SMA to monitor SPY you will need to modify the code I sent you so that it incorporates your second data series into your SMA indicator, e.g.

Code:
 _smaSPY = SMAPanel2(BarsArray[1], Closes[1], 50);
If neither of these was quite what you were looking for or there is any other way we can help please let us know.
NinjaTrader_JessicaP is offline  
Reply With Quote
Old 02-23-2017, 06:36 AM   #8
JBU1314
Member
 
Join Date: Jul 2015
Posts: 64
Thanks: 17
Thanked 1 time in 1 post
Default

Thank you very much Jessica. This is what I was looking for. I will try to be more specific next time!
Have a great day!
JBU1314 is offline  
Reply With Quote
Old 02-23-2017, 08:14 AM   #9
JBU1314
Member
 
Join Date: Jul 2015
Posts: 64
Thanks: 17
Thanked 1 time in 1 post
Default

Jessica, only problem now is that the method in your provided code does only allow for 2 arguments and not 3 as you provided.
_smaSPY = SMAPanel2(BarsArray[1], Closes[1], 50);
if i adjust to
_smaSPY = SMAPanel2(BarsArray[1], 50);
I still only have AAPL presented in the SMA Panel.
JBU1314 is offline  
Reply With Quote
Old 02-23-2017, 08:53 AM   #10
JBU1314
Member
 
Join Date: Jul 2015
Posts: 64
Thanks: 17
Thanked 1 time in 1 post
Default

Maybe it helps to outline that part of my code again:
2 DataSeries APPL & SPY - I want to go long if
Close of APPL is above x-Period SMA of APPL
AND
SMA of SPY is rising (Close[0] > Close[1])
AND
I also want to see the SMA of SPY on my chart
JBU1314 is offline  
Reply With Quote
Old 02-23-2017, 09:54 AM   #11
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,422
Thanks: 206
Thanked 522 times in 509 posts
Default

I did have a typo present. If you use BarsArray[1] in your SMA, your SMA will be processing over the SPY even if the label shows your primary instrument (AAPL). You can test this by adding another SMA(BarsArray[0]), or adding an SMA indicator on either instrument outside your strategy.
NinjaTrader_JessicaP is offline  
Reply With Quote
Old 02-23-2017, 10:16 AM   #12
JBU1314
Member
 
Join Date: Jul 2015
Posts: 64
Thanks: 17
Thanked 1 time in 1 post
Default

how can we change the label?
JBU1314 is offline  
Reply With Quote
Old 02-24-2017, 09:23 AM   #13
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,422
Thanks: 206
Thanked 522 times in 509 posts
Default

You can add this to the SMAPanel2 indicator's Properties section

Code:

        public string UsedInstrument
        { get; set; }

        public override string DisplayName
        {
            get { return "SMA(" + UsedInstrument + ", " + Period + ")"; }
        }
You will then want to make sure you set this indicator's UsedInstrument manually.
NinjaTrader_JessicaP 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
Indicator on 2nd data series meyer99 Platform Technical Support 1 12-08-2016 04:17 PM
Can't Draw In 2nd Data Series Panel 2 tradenj General Development 5 03-10-2013 01:52 PM
Can indicator draw on its own panel as well as the Input Series upshon Indicator Development 1 12-22-2010 07:35 AM
2nd data series mballagan Strategy Development 1 12-07-2009 11:36 AM


All times are GMT -6. The time now is 08:09 AM.

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.