![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
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); kc |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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]);
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
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... |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
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; |
|
|
|
|
The following user says thank you to kcsystemtrader for this post: |
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Great, thanks for identifying this. I've confirmed on my side and reported to development. I will update this thread with any new information.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Nov 2008
Posts: 168
Thanks: 2
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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.
Brett
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Brett for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |