NinjaTrader Support Forum  

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 03-14-2010, 09:19 AM   #1
Mike Winfrey
Senior Member
 
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
Default Retrieve PeriodType

How do I programmatically get the PeriodType of the current chart for use within Initialize()?

Thanks,
Mike
Last edited by Mike Winfrey; 03-14-2010 at 09:24 AM. Reason: More information
Mike Winfrey is offline  
Reply With Quote
Old 03-14-2010, 11:17 AM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

I don't think you can. No bars are available in the Initialization() block.

This is how you check bar types though:

if
(Bars.Period.Id == PeriodType.Tick )
{
// Indicator calculation logic here
}

http://www.ninjatrader-support.com/H...V6/Period.html
NinjaTrader_Ben is offline  
Reply With Quote
Old 03-15-2010, 05:52 AM   #3
Mike Winfrey
Senior Member
 
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
Default

Thanks Ben
Mike Winfrey is offline  
Reply With Quote
Old 03-15-2010, 06:19 AM   #4
Mike Winfrey
Senior Member
 
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
Default

This may not change your answer but thought I'd be more specific just in case.

In the Initialize() method I have

Add("$GBPUSD", periodtype, timeframe);

Currently, I set periodtype by means of a parameter and actually use PeriodType.Minute. However, I'd like to be able to get the interval setting that is used when opening a new chart and set my periodtype variable based on the chart interval setting instead of through the static parameter.

I hope I'm expressing this well enough.

Thanks again,
Mike
Mike Winfrey is offline  
Reply With Quote
Old 03-15-2010, 10:04 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Mike, thanks for clarifying - accessing this property dynamically is unfortunately not supported.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-15-2010, 10:10 AM   #6
Mike Winfrey
Senior Member
 
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
Default

Well shucks...thanks Bertrand
Mike Winfrey is offline  
Reply With Quote
Old 04-14-2010, 10:16 AM   #7
xTrader1
Senior Member
 
Join Date: Apr 2009
Posts: 208
Thanks: 0
Thanked 4 times in 3 posts
Default Did you find any way to do it ?

Quote:
Originally Posted by Mike Winfrey View Post
Well shucks...thanks Bertrand
Also , see my new thread :
http://www.ninjatrader-support2.com/...d.php?p=158635
xTrader1 is offline  
Reply With Quote
Old 04-14-2010, 10:29 AM   #8
Mike Winfrey
Senior Member
 
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
Default

No I didn't and gave up.
Mike Winfrey 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
Custom PeriodType Mike Winfrey Indicator Development 12 01-28-2013 08:19 AM
Add RangeAlt to PeriodType. shawnj Suggestions And Feedback 1 10-10-2009 06:34 PM
get the periodtype tomleeson General Programming 4 07-30-2009 04:57 AM
PeriodType.RangeAlt snaphook General Programming 2 11-13-2008 08:19 AM
Question about PeriodType.Tick Edgar V. Strategy Development 2 03-19-2008 03:47 PM


All times are GMT -6. The time now is 06:32 AM.