NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

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

Reply
 
Thread Tools Display Modes
Old 10-24-2011, 09:51 AM   #1
kcsystemtrader
Member
 
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
Default Plotting Indicators in Multi-Time Frame Strategies

I am launching a strategy on a 1 min chart, and have the following code in initialize():

Code:
Add(SMA(10);
Add(SMA(20);
Add(PeriodType.Minute, 5);
I expected the two SMA indicators to begin plotting on the 1 min chart, but they do not. Will they not plot if you are running strategies with an additional bars object?

kc
kcsystemtrader is offline  
Reply With Quote
Old 10-24-2011, 10:01 AM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi KC,

These add statements work differently.
Add(SMA(10);
Add(SMA(20);

These add the indicators for visualization only, and is always based on the primary series unless the actual indicator (SMA in your example) is coded for multiple series.

Add(PeriodType.Minute, 5);

This adds a 5 minute series to the script, but you would need to work the series into your code to have any use from it. There is a sample multiTimeFrame strategy built into all NinjaScript installations through Tools > Edit NinjaScript > Strategy menu. Documentation for this is available here:
http://www.ninjatrader.com/support/h...nstruments.htm

To set a plot based on the first added series, you would use something like:
Value.Set(SMA(Closes[1], 14)[0]);
NinjaTrader_RyanM is offline  
Reply With Quote
Old 10-24-2011, 10:32 AM   #3
kcsystemtrader
Member
 
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
Default

Thanks Ryan. I understand that the first add calls are for visualization only, and that the other add call is for adding another time frame. The issue is that the SMA indicators are not showing up on the chart (i.e. no visualization) as expected on the primary bars object (i.e. 1 min time frame chart that the strategy is loaded on). I'm not trying to plot anything related to the secondary bars object.

I am able to get them to show up on a basic strategy where I've simplified the code, so it is isolated to just one strategy...nothing in the logs...I'll have to keep troubleshooting to see if I can isolate where the issue is occuring...
kcsystemtrader is offline  
Reply With Quote
Old 10-24-2011, 10:46 AM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

I see, thanks for the reply. Would normally expect to see something in the logs if it doesn't display the indicators. If you have a simple script where this can be seen I'm happy to give it a run here to see if I'm able to spot it.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 10-24-2011, 12:19 PM   #5
kcsystemtrader
Member
 
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
Default

Ok, the issue seems to be with ForceMaximumBarsLookBack256 = true. There are plenty of bars on the chart to draw the indicators. Testing this on ES 1-Min time frame with ESignal data feed. If you copy the following into initialize, it does not plot the indicators. Then uncomment out the top block of code and comment out the bottom and it does plot the indicators

Code:

// This code plots the indicators
// Add(SMA(10));
// Add(SMA(20));
// SMA(10).Plots[0].Pen.Color = Color.Red;
// SMA(20).Plots[0].Pen.Color = Color.Blue;
// Add(PeriodType.Minute, 5);
// //ForceMaximumBarsLookBack256 = true;
// CalculateOnBarClose = true;


// This code does not
Add(SMA(10));
Add(SMA(20));
SMA(10).Plots[0].Pen.Color = Color.Red;
SMA(20).Plots[0].Pen.Color = Color.Blue;
Add(PeriodType.Minute, 5);
ForceMaximumBarsLookBack256 = true;
CalculateOnBarClose = true;
kcsystemtrader is offline  
Reply With Quote
The following user says thank you to kcsystemtrader for this post:
Old 10-24-2011, 01:09 PM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Great, thanks for identifying this. I've confirmed on my side and reported to development. I will update this thread with any new information.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 12-29-2011, 10:54 PM   #7
heyligerb
Senior Member
 
Join Date: Nov 2008
Posts: 168
Thanks: 2
Thanked 0 times in 0 posts
Default

I'm having a similar issue... and per your recommendation, when I add "Value.Set(SMA(Closes[1], 14)[0]);" into my code, I get the "The name 'Value' does not exist in the curr..."

All I want to do is plot the MAs I'm using for trade generation.
heyligerb is offline  
Reply With Quote
Old 12-30-2011, 06:22 AM   #8
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks for the forum post.

You most likely are missing the parts of the below sample that create Value for you to be able to set it, this needs to be added since you are doing this inside a strategy. If you are not doing this inside of a strategy please let me know and ignore the following. This is only if you are running in a strategy and not an indicator.

In summary what you are doing is adding a plot from inside the strategy the values of the secondary series SMA.

You need to insure you have all the code in the following sample:

http://www.ninjatrader.com/support/f...ead.php?t=6651

Including:

Add(StrategyPlot(0));
StrategyPlot(0).PanelUI = 1;


StrategyPlot(0).Value.Set(SMA(Closes[1], 14)[0]);

And also importing in the indicator in that sample into your indicator list called StrategyPlot for the strategy plot to work correctly.

Let me know if any questions.
NinjaTrader_Brett is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Brett 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
Multi Time Frame Indicators tshirtdeal Charting 1 02-19-2011 04:28 PM
Multi Time Frame plotting question gyoung Version 7 Beta General Questions & Bug Reports 5 03-18-2010 02:08 PM
multi time frame indicators markw Suggestions And Feedback 1 01-17-2009 12:33 PM
Indicators on Multi Time Frame SystemTrading Strategy Development 3 10-22-2008 09:33 AM
Plotting values on multi-time frame and instruments chart SuzyG Strategy Development 1 01-19-2007 12:32 AM


All times are GMT -6. The time now is 12:31 AM.