NinjaTrader Support Forum  

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

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

Reply
 
Thread Tools Display Modes
Old 02-25-2011, 03:40 PM   #1
darckeen
Senior Member
 
Join Date: Feb 2009
Posts: 177
Thanks: 0
Thanked 0 times in 0 posts
Default series of indicator of indicator changing update policy

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);
}
}
}
gives this output:
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
when you change the OnStartUp to

Code:
 
indicator = SMA(Closes[1],8);
// indicator = SMA(BarChange(Closes[1]),8);
the results are as expected:

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
darckeen is offline  
Reply With Quote
Old 02-25-2011, 03:59 PM   #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

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.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 02-27-2011, 10:40 PM   #3
darckeen
Senior Member
 
Join Date: Feb 2009
Posts: 177
Thanks: 0
Thanked 0 times in 0 posts
Default

I'm finding that using SMA rather then IDataSeries as the class causes the same unexpected behavior.
darckeen is offline  
Reply With Quote
Old 02-28-2011, 08:38 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

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"?
NinjaTrader_RyanM 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
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


All times are GMT -6. The time now is 09:37 PM.