![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Feb 2009
Posts: 177
Thanks: 0
Thanked 0 times in 0 posts
|
Hey NT crew,
I've got a multi-granularity strategy that uses a indicator of another indicator in the second granularity. It appears that adding the indicator as an IDataSeries is causing the update policy to change for all the indicators in the strategy. Is there anyway you know of to avoid this and keep the indicator as an IDataSeries? Code:
namespace NinjaTrader.Strategy
{
public class UpdateIssue : Strategy
{
private IDataSeries indicator;
protected override void Initialize()
{
Add(BarsPeriod.Id,5);
CalculateOnBarClose = true;
}
protected override void OnStartUp()
{
ClearOutputWindow();
// indicator = SMA(Closes[1],8);
indicator = SMA(BarChange(Closes[1]),8);
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0) return;
DateTime barTime = Times[BarsInProgress][0];
string time = string.Format("{0:g}\t{1:0.00}",barTime,Closes[1][0]);
string test1 = string.Format("\t{0:0.00}",BarChange(Closes[1])[0]);
string test2 = string.Format("\t{0:0.00}",SMA(BarChange(Closes[1]),8)[0]);
string test3 = string.Format("\t{0:0.00}",indicator[0]);
Print(time + test1 + test2 + test3);
}
}
}
Code:
2/10/2011 3:52 PM 132.41 0.16 0.07 0.07 2/10/2011 3:53 PM 132.41 0.16 0.08 0.08 2/10/2011 3:54 PM 132.41 0.16 0.10 0.10 2/10/2011 3:55 PM 131.99 -0.43 0.05 0.05 2/10/2011 3:56 PM 131.99 -0.43 -0.01 -0.01 2/10/2011 3:57 PM 131.99 -0.43 -0.06 -0.06 2/10/2011 3:58 PM 131.99 -0.43 -0.13 -0.13 2/10/2011 3:59 PM 131.99 -0.43 -0.21 -0.21 Code:
indicator = SMA(Closes[1],8); // indicator = SMA(BarChange(Closes[1]),8); Code:
2/10/2011 3:52 PM 132.41 0.16 0.05 132.19 2/10/2011 3:53 PM 132.41 0.16 0.05 132.19 2/10/2011 3:54 PM 132.41 0.16 0.05 132.19 2/10/2011 3:55 PM 131.99 -0.43 -0.01 132.18 2/10/2011 3:56 PM 131.99 -0.43 -0.01 132.18 2/10/2011 3:57 PM 131.99 -0.43 -0.01 132.18 2/10/2011 3:58 PM 131.99 -0.43 -0.01 132.18 2/10/2011 3:59 PM 131.99 -0.43 -0.01 132.18 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello darckeen,
For custom data series, you can follow according to this post: http://www.ninjatrader.com/support/f...ead.php?t=7299 To create an indicator instance: private SMA mySMA; //variables region mySMA = SMA(BarChange(Closes[1]),8); //OnStartup() I'm not sure what private IDataSeries indicator; is doing but it's not typically used like this.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Feb 2009
Posts: 177
Thanks: 0
Thanked 0 times in 0 posts
|
I'm finding that using SMA rather then IDataSeries as the class causes the same unexpected behavior.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi darckeen,
Can you please provide a code snippet that's not working the way you expect. Also, include a description of what you expect it to do and what you're seeing happen instead. From your original post, can you clarify "update policy"?
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple Data Series with different Indicator Input series | marotom | General Programming | 5 | 01-06-2011 12:11 PM |
| Retrieving price data when indicator input series is another indicator | MikeInMA | Indicator Development | 6 | 01-06-2011 07:33 AM |
| indicator update | sergeysamsonov | Indicator Development | 1 | 10-08-2010 01:46 PM |
| cannot update indicator | Harry | Miscellaneous Support | 15 | 12-03-2009 01:27 PM |
| Make trail stop value update intra bar without indicator update. | dendy | Strategy Development | 26 | 10-21-2007 09:14 AM |