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 > Indicator Development

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

Reply
 
Thread Tools Display Modes
Old 01-04-2012, 08:53 AM   #1
traderjem
Junior Member
 
Join Date: Dec 2010
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default Multi TimeFrame Indicator Help

I am currently developing multi timeframe indicators. For example, below I developed a simple adx mult timeframe indicator that I can use with range bar types. What I would like to do is adjust this program to be able to receive any type (i.e. minutes, seconds, ticks, etc...) instead of only range. Can anyone give me some guidance on how I would approach this?

protected override void Initialize()
{
Add(PeriodType.Range, range);
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "ADXComp Line"));
Overlay = false;
CalculateOnBarClose = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
return;
double ADXComp = (ADX(BarsArray[1],adxperiod)[0]);
ADXCompLine.Set(ADXComp);
}
traderjem is offline  
Reply With Quote
Old 01-04-2012, 08:58 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 traderjem,

Thanks for the post and welcome to the NinjaTrader forums! For timing reasons, we support only hard coding additional series. This is controlled with the Add() statements, possible values are available here:
http://www.ninjatrader.com/support/h...s/nt7/add3.htm
NinjaTrader_RyanM is offline  
Reply With Quote
Old 01-04-2012, 09:16 AM   #3
traderjem
Junior Member
 
Join Date: Dec 2010
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default

Hey Ryan

So are you saying I should ADD each potential period type I want and then send a flag from my properties to tell it which type to use (like in a case statement)?
traderjem is offline  
Reply With Quote
Old 01-04-2012, 09:27 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

That could be one way to do it. There is no supported technique for conditionally adding series to your script but you could add all potential series you need. Then work a case statement into OnBarUpdate() for accessing.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 02-24-2012, 03:04 PM   #5
anachronist
Senior Member
 
Join Date: Jul 2008
Posts: 271
Thanks: 4
Thanked 7 times in 7 posts
Default

Quote:
Originally Posted by NinjaTrader_RyanM View Post
That could be one way to do it. There is no supported technique for conditionally adding series to your script but you could add all potential series you need. Then work a case statement into OnBarUpdate() for accessing.
That reminds me -- for a long time now I have wanted the ability to use Add() in OnStartUp(). Such an action, of course, would mean that the properties of whatever is added isn't accessible from the indicator properties. And it would also probably mean that something in OnTermination() would be needed to destroy whatever got added. But this would be a nice way to handle the need to add things conditionally based on the input parameters.

It strikes me as wasteful of both memory and CPU to add every possible time frame and then use just one of them.

-A
anachronist is offline  
Reply With Quote
The following user says thank you to anachronist 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 timeframe indicator pbayer Indicator Development 1 05-09-2011 04:46 PM
looking for example 6.5 multi-timeframe indicator tulanch Indicator Development 2 10-08-2010 12:09 PM
Multi timeframe indicator sergeysamsonov Indicator Development 1 07-26-2010 06:08 AM
Multi-Timeframe indicator velocity Version 7 Beta General Questions & Bug Reports 3 12-23-2009 11:28 AM
Multi-timeframe indicator referencing LazKz Strategy Development 3 03-18-2009 07:24 AM


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